Ignore:
Timestamp:
Feb 28, 2019, 4:04:51 PM (6 years ago)
Author:
[email protected]
Message:

In cloop.rb, rename :int and :uint to :intptr and :uintptr.
https://bugs.webkit.org/show_bug.cgi?id=195183

Reviewed by Yusuke Suzuki.

Also changed intMemRef and uintMemRef to intptrMemRef and uintptrMemRef respectively.

  • offlineasm/cloop.rb:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/cloop.rb

    r242215 r242240  
    3434def cloopMapType(type)
    3535    case type
    36     when :int;            ".i()"
    37     when :uint;           ".u()"
     36    when :intptr;         ".i()"
     37    when :uintptr;        ".u()"
    3838    when :int32;          ".i32()"
    3939    when :uint32;         ".u32()"
     
    5656
    5757class SpecialRegister < NoChildren
    58     def clLValue(type=:int)
     58    def clLValue(type=:intptr)
    5959        clDump
    6060    end
     
    6262        @name
    6363    end
    64     def clValue(type=:int)
     64    def clValue(type=:intptr)
    6565        @name + cloopMapType(type)
    6666    end
     
    104104        end
    105105    end
    106     def clLValue(type=:int)
     106    def clLValue(type=:intptr)
    107107        clDump
    108108    end
    109     def clValue(type=:int)
     109    def clValue(type=:intptr)
    110110        clDump + cloopMapType(type)
    111111    end
     
    131131        end
    132132    end
    133     def clLValue(type=:int)
     133    def clLValue(type=:intptr)
    134134        clDump
    135135    end
    136     def clValue(type=:int)
     136    def clValue(type=:intptr)
    137137        clDump + cloopMapType(type)
    138138    end
     
    143143        "#{value}"
    144144    end
    145     def clLValue(type=:int)
     145    def clLValue(type=:intptr)
    146146        raise "Immediate cannot be used as an LValue"
    147147    end
    148     def clValue(type=:int)
     148    def clValue(type=:intptr)
    149149        # There is a case of a very large unsigned number (0x8000000000000000)
    150150        # which we wish to encode.  Unfortunately, the C/C++ compiler
     
    163163        when :int32;   "int32_t(#{valueStr})"
    164164        when :int64;   "int64_t(#{valueStr})"
    165         when :int;     "intptr_t(#{valueStr})"
     165        when :intptr;  "intptr_t(#{valueStr})"
    166166        when :uint8;   "uint8_t(#{valueStr})"
    167167        when :uint32;  "uint32_t(#{valueStr})"
    168168        when :uint64;  "uint64_t(#{valueStr})"
    169         when :uint;    "uintptr_t(#{valueStr})"
     169        when :uintptr; "uintptr_t(#{valueStr})"
    170170        else
    171171            raise "Not implemented immediate of type: #{type}"
     
    178178        "[#{base.clDump}, #{offset.value}]"
    179179    end
    180     def clLValue(type=:int)
     180    def clLValue(type=:intptr)
    181181        clValue(type)
    182182    end
    183     def clValue(type=:int)
     183    def clValue(type=:intptr)
    184184        case type
    185185        when :int8;         int8MemRef
    186186        when :int32;        int32MemRef
    187187        when :int64;        int64MemRef
    188         when :int;          intMemRef
     188        when :intptr;       intptrMemRef
    189189        when :uint8;        uint8MemRef
    190190        when :uint32;       uint32MemRef
    191191        when :uint64;       uint64MemRef
    192         when :uint;         uintMemRef
     192        when :uintptr;      uintptrMemRef
    193193        when :opcode;       opcodeMemRef
    194194        when :nativeFunc;   nativeFuncMemRef
     
    218218        "*CAST<int64_t*>(#{pointerExpr})"
    219219    end
    220     def intMemRef
     220    def intptrMemRef
    221221        "*CAST<intptr_t*>(#{pointerExpr})"
    222222    end
     
    233233        "*CAST<uint64_t*>(#{pointerExpr})"
    234234    end
    235     def uintMemRef
     235    def uintptrMemRef
    236236        "*CAST<uintptr_t*>(#{pointerExpr})"
    237237    end
     
    251251        "[#{base.clDump}, #{offset.clDump}, #{index.clDump} << #{scaleShift}]"
    252252    end
    253     def clLValue(type=:int)
     253    def clLValue(type=:intptr)
    254254        clValue(type)
    255255    end
    256     def clValue(type=:int)
     256    def clValue(type=:intptr)
    257257        case type
    258258        when :int8;       int8MemRef
    259259        when :int32;      int32MemRef
    260260        when :int64;      int64MemRef
    261         when :int;        intMemRef
     261        when :intptr;     intptrMemRef
    262262        when :uint8;      uint8MemRef
    263263        when :uint32;     uint32MemRef
    264264        when :uint64;     uint64MemRef
    265         when :uint;       uintMemRef
     265        when :uintptr;    uintptrMemRef
    266266        when :opcode;     opcodeMemRef
    267267        else
     
    288288        "*CAST<int64_t*>(#{pointerExpr})"
    289289    end
    290     def intMemRef
     290    def intptrMemRef
    291291        "*CAST<intptr_t*>(#{pointerExpr})"
    292292    end
     
    303303        "*CAST<uint64_t*>(#{pointerExpr})"
    304304    end
    305     def uintMemRef
     305    def uintptrMemRef
    306306        "*CAST<uintptr_t*>(#{pointerExpr})"
    307307    end
     
    318318        "#{codeOriginString}"
    319319    end
    320     def clLValue(type=:int)
     320    def clLValue(type=:intptr)
    321321        clValue(type)
    322322    end
     
    327327
    328328class LabelReference
    329     def intMemRef
     329    def intptrMemRef
    330330        "*CAST<intptr_t*>(&#{cLabel})"
    331331    end
     
    386386
    387387def 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 || \
    389389        type == :int64 || type == :uint64 || type == :double
    390390    if operands.size == 3
     
    410410
    411411def cloopEmitShiftOperation(operands, type, operator)
    412     raise unless type == :int || type == :uint || type == :int32 || type == :uint32 || type == :int64 || type == :uint64
     412    raise unless type == :intptr || type == :uintptr || type == :int32 || type == :uint32 || type == :int64 || type == :uint64
    413413    if operands.size == 3
    414414        op1 = operands[0]
     
    427427        truncationFooter = ""
    428428    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
    432430    shiftMask = "0x3f" if type == :int64 || type == :uint64
    433431    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};"
    435433end
    436434
    437435def cloopEmitUnaryOperation(operands, type, operator)
    438     raise unless type == :int || type == :uint || type == :int32 || type == :uint32 || type == :int64 || type == :uint64
     436    raise unless type == :intptr || type == :uintptr || type == :int32 || type == :uint32 || type == :int64 || type == :uint64
    439437    raise unless operands.size == 1
    440438    raise unless not operands[0].is_a? Immediate
     
    507505def cloopEmitOpAndBranch(operands, operator, type, conditionTest)
    508506    case type
    509     when :int tempType = "intptr_t"
     507    when :intptr; tempType = "intptr_t"
    510508    when :int32; tempType = "int32_t"
    511509    when :int64; tempType = "int64_t"
     
    573571            cloopEmitOperation(operands, :int64, "+")
    574572        when "addp"
    575             cloopEmitOperation(operands, :int, "+")
     573            cloopEmitOperation(operands, :intptr, "+")
    576574
    577575        when "andi"
     
    580578            cloopEmitOperation(operands, :int64, "&")
    581579        when "andp"
    582             cloopEmitOperation(operands, :int, "&")
     580            cloopEmitOperation(operands, :intptr, "&")
    583581
    584582        when "ori"
     
    587585            cloopEmitOperation(operands, :int64, "|")
    588586        when "orp"
    589             cloopEmitOperation(operands, :int, "|")
     587            cloopEmitOperation(operands, :intptr, "|")
    590588
    591589        when "xori"
     
    594592            cloopEmitOperation(operands, :int64, "^")
    595593        when "xorp"
    596             cloopEmitOperation(operands, :int, "^")
     594            cloopEmitOperation(operands, :intptr, "^")
    597595
    598596        when "lshifti"
     
    601599            cloopEmitShiftOperation(operands, :int64, "<<")
    602600        when "lshiftp"
    603             cloopEmitShiftOperation(operands, :int, "<<")
     601            cloopEmitShiftOperation(operands, :intptr, "<<")
    604602
    605603        when "rshifti"
     
    608606            cloopEmitShiftOperation(operands, :int64, ">>")
    609607        when "rshiftp"
    610             cloopEmitShiftOperation(operands, :int, ">>")
     608            cloopEmitShiftOperation(operands, :intptr, ">>")
    611609
    612610        when "urshifti"
     
    615613            cloopEmitShiftOperation(operands, :uint64, ">>")
    616614        when "urshiftp"
    617             cloopEmitShiftOperation(operands, :uint, ">>")
     615            cloopEmitShiftOperation(operands, :uintptr, ">>")
    618616
    619617        when "muli"
     
    622620            cloopEmitOperation(operands, :int64, "*")
    623621        when "mulp"
    624             cloopEmitOperation(operands, :int, "*")
     622            cloopEmitOperation(operands, :intptr, "*")
    625623
    626624        when "subi"
     
    629627            cloopEmitOperation(operands, :int64, "-")
    630628        when "subp"
    631             cloopEmitOperation(operands, :int, "-")
     629            cloopEmitOperation(operands, :intptr, "-")
    632630
    633631        when "negi"
     
    636634            cloopEmitUnaryOperation(operands, :int64, "-")
    637635        when "negp"
    638             cloopEmitUnaryOperation(operands, :int, "-")
     636            cloopEmitUnaryOperation(operands, :intptr, "-")
    639637
    640638        when "noti"
     
    650648            $asm.putc "#{operands[1].clLValue(:int64)} = #{operands[0].int64MemRef};"
    651649        when "loadp"
    652             $asm.putc "#{operands[1].clLValue} = #{operands[0].intMemRef};"
     650            $asm.putc "#{operands[1].clLValue} = #{operands[0].intptrMemRef};"
    653651        when "storei"
    654652            $asm.putc "#{operands[1].int32MemRef} = #{operands[0].clValue(:int32)};"
     
    656654            $asm.putc "#{operands[1].int64MemRef} = #{operands[0].clValue(:int64)};"
    657655        when "storep"
    658             $asm.putc "#{operands[1].intMemRef} = #{operands[0].clValue(:int)};"
     656            $asm.putc "#{operands[1].intptrMemRef} = #{operands[0].clValue(:intptr)};"
    659657        when "loadb"
    660             $asm.putc "#{operands[1].clLValue(:int)} = #{operands[0].uint8MemRef};"
     658            $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].uint8MemRef};"
    661659        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});"
    663661        when "loadbsp"
    664             $asm.putc "#{operands[1].clLValue(:int)} = #{operands[0].int8MemRef};"
     662            $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].int8MemRef};"
    665663        when "storeb"
    666664            $asm.putc "#{operands[1].uint8MemRef} = #{operands[0].clValue(:int8)};"
    667665        when "loadh"
    668             $asm.putc "#{operands[1].clLValue(:int)} = #{operands[0].uint16MemRef};"
     666            $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].uint16MemRef};"
    669667        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});"
    671669        when "storeh"
    672670            $asm.putc "*#{operands[1].uint16MemRef} = #{operands[0].clValue(:int16)};"
     
    716714
    717715        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"
    719717
    720718        when "bcd2i"  # operands: srcDbl dstInt slowPath
     
    728726
    729727        when "move"
    730             $asm.putc "#{operands[1].clLValue(:int)} = #{operands[0].clValue(:int)};"
     728            $asm.putc "#{operands[1].clLValue(:intptr)} = #{operands[0].clValue(:intptr)};"
    731729        when "sxi2q"
    732730            $asm.putc "#{operands[1].clLValue(:int64)} = #{operands[0].clValue(:int32)};"
     
    742740            cloopEmitCompareAndBranch(operands, :int64, "==")
    743741        when "bpeq"
    744             cloopEmitCompareAndBranch(operands, :int, "==")
     742            cloopEmitCompareAndBranch(operands, :intptr, "==")
    745743
    746744        when "bbneq"
     
    751749            cloopEmitCompareAndBranch(operands, :int64, "!=")
    752750        when "bpneq"
    753             cloopEmitCompareAndBranch(operands, :int, "!=")
     751            cloopEmitCompareAndBranch(operands, :intptr, "!=")
    754752
    755753        when "bba"
     
    760758            cloopEmitCompareAndBranch(operands, :uint64, ">")
    761759        when "bpa"
    762             cloopEmitCompareAndBranch(operands, :uint, ">")
     760            cloopEmitCompareAndBranch(operands, :uintptr, ">")
    763761
    764762        when "bbaeq"
     
    769767            cloopEmitCompareAndBranch(operands, :uint64, ">=")
    770768        when "bpaeq"
    771             cloopEmitCompareAndBranch(operands, :uint, ">=")
     769            cloopEmitCompareAndBranch(operands, :uintptr, ">=")
    772770
    773771        when "bbb"
     
    778776            cloopEmitCompareAndBranch(operands, :uint64, "<")
    779777        when "bpb"
    780             cloopEmitCompareAndBranch(operands, :uint, "<")
     778            cloopEmitCompareAndBranch(operands, :uintptr, "<")
    781779
    782780        when "bbbeq"
     
    787785            cloopEmitCompareAndBranch(operands, :uint64, "<=")
    788786        when "bpbeq"
    789             cloopEmitCompareAndBranch(operands, :uint, "<=")
     787            cloopEmitCompareAndBranch(operands, :uintptr, "<=")
    790788
    791789        when "bbgt"
     
    796794            cloopEmitCompareAndBranch(operands, :int64, ">")
    797795        when "bpgt"
    798             cloopEmitCompareAndBranch(operands, :int, ">")
     796            cloopEmitCompareAndBranch(operands, :intptr, ">")
    799797
    800798        when "bbgteq"
     
    805803            cloopEmitCompareAndBranch(operands, :int64, ">=")
    806804        when "bpgteq"
    807             cloopEmitCompareAndBranch(operands, :int, ">=")
     805            cloopEmitCompareAndBranch(operands, :intptr, ">=")
    808806
    809807        when "bblt"
     
    814812            cloopEmitCompareAndBranch(operands, :int64, "<")
    815813        when "bplt"
    816             cloopEmitCompareAndBranch(operands, :int, "<")
     814            cloopEmitCompareAndBranch(operands, :intptr, "<")
    817815
    818816        when "bblteq"
     
    823821            cloopEmitCompareAndBranch(operands, :int64, "<=")
    824822        when "bplteq"
    825             cloopEmitCompareAndBranch(operands, :int, "<=")
     823            cloopEmitCompareAndBranch(operands, :intptr, "<=")
    826824
    827825        when "btbz"
     
    832830            cloopEmitTestAndBranchIf(operands, :int64, "== 0", operands[-1].cLabel)
    833831        when "btpz"
    834             cloopEmitTestAndBranchIf(operands, :int, "== 0", operands[-1].cLabel)
     832            cloopEmitTestAndBranchIf(operands, :intptr, "== 0", operands[-1].cLabel)
    835833
    836834        when "btbnz"
     
    841839            cloopEmitTestAndBranchIf(operands, :int64, "!= 0", operands[-1].cLabel)
    842840        when "btpnz"
    843             cloopEmitTestAndBranchIf(operands, :int, "!= 0", operands[-1].cLabel)
     841            cloopEmitTestAndBranchIf(operands, :intptr, "!= 0", operands[-1].cLabel)
    844842
    845843        when "btbs"
     
    850848            cloopEmitTestAndBranchIf(operands, :int64, "< 0", operands[-1].cLabel)
    851849        when "btps"
    852             cloopEmitTestAndBranchIf(operands, :int, "< 0", operands[-1].cLabel)
     850            cloopEmitTestAndBranchIf(operands, :intptr, "< 0", operands[-1].cLabel)
    853851
    854852        # For jmp, we do not want to assume that we have COMPUTED_GOTO support.
     
    886884            cloopEmitCompareAndSet(operands, :uint64, "==")
    887885        when "cpeq"
    888             cloopEmitCompareAndSet(operands, :uint, "==")
     886            cloopEmitCompareAndSet(operands, :uintptr, "==")
    889887
    890888        when "cbneq"
     
    895893            cloopEmitCompareAndSet(operands, :uint64, "!=")
    896894        when "cpneq"
    897             cloopEmitCompareAndSet(operands, :uint, "!=")
     895            cloopEmitCompareAndSet(operands, :uintptr, "!=")
    898896
    899897        when "cba"
     
    904902            cloopEmitCompareAndSet(operands, :uint64, ">")
    905903        when "cpa"
    906             cloopEmitCompareAndSet(operands, :uint, ">")
     904            cloopEmitCompareAndSet(operands, :uintptr, ">")
    907905
    908906        when "cbaeq"
     
    913911            cloopEmitCompareAndSet(operands, :uint64, ">=")
    914912        when "cpaeq"
    915             cloopEmitCompareAndSet(operands, :uint, ">=")
     913            cloopEmitCompareAndSet(operands, :uintptr, ">=")
    916914
    917915        when "cbb"
     
    922920            cloopEmitCompareAndSet(operands, :uint64, "<")
    923921        when "cpb"
    924             cloopEmitCompareAndSet(operands, :uint, "<")
     922            cloopEmitCompareAndSet(operands, :uintptr, "<")
    925923
    926924        when "cbbeq"
     
    931929            cloopEmitCompareAndSet(operands, :uint64, "<=")
    932930        when "cpbeq"
    933             cloopEmitCompareAndSet(operands, :uint, "<=")
     931            cloopEmitCompareAndSet(operands, :uintptr, "<=")
    934932
    935933        when "cbgt"
     
    940938            cloopEmitCompareAndSet(operands, :int64, ">")
    941939        when "cpgt"
    942             cloopEmitCompareAndSet(operands, :int, ">")
     940            cloopEmitCompareAndSet(operands, :intptr, ">")
    943941
    944942        when "cbgteq"
     
    949947            cloopEmitCompareAndSet(operands, :int64, ">=")
    950948        when "cpgteq"
    951             cloopEmitCompareAndSet(operands, :int, ">=")
     949            cloopEmitCompareAndSet(operands, :intptr, ">=")
    952950
    953951        when "cblt"
     
    958956            cloopEmitCompareAndSet(operands, :int64, "<")
    959957        when "cplt"
    960             cloopEmitCompareAndSet(operands, :int, "<")
     958            cloopEmitCompareAndSet(operands, :intptr, "<")
    961959
    962960        when "cblteq"
     
    967965            cloopEmitCompareAndSet(operands, :int64, "<=")
    968966        when "cplteq"
    969             cloopEmitCompareAndSet(operands, :int, "<=")
     967            cloopEmitCompareAndSet(operands, :intptr, "<=")
    970968
    971969        when "tbs"
     
    976974            cloopEmitTestSet(operands, :int64, "< 0")
    977975        when "tps"
    978             cloopEmitTestSet(operands, :int, "< 0")
     976            cloopEmitTestSet(operands, :intptr, "< 0")
    979977
    980978        when "tbz"
     
    985983            cloopEmitTestSet(operands, :int64, "== 0")
    986984        when "tpz"
    987             cloopEmitTestSet(operands, :int, "== 0")
     985            cloopEmitTestSet(operands, :intptr, "== 0")
    988986
    989987        when "tbnz"
     
    994992            cloopEmitTestSet(operands, :int64, "!= 0")
    995993        when "tpnz"
    996             cloopEmitTestSet(operands, :int, "!= 0")
     994            cloopEmitTestSet(operands, :intptr, "!= 0")
    997995
    998996        # 64-bit instruction: cdqi (based on X64)
     
    10211019            $asm.putc "{ // idivi"
    10221020            $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)};"
    10241022            $asm.putc "    t1 = (uint32_t)(dividend % divisor); // remainder"
    10251023            $asm.putc "    t0 = (uint32_t)(dividend / divisor); // quotient"
     
    10491047            operands[0].cloopEmitLea(operands[1], :int32)
    10501048        when "leap"
    1051             operands[0].cloopEmitLea(operands[1], :int)
     1049            operands[0].cloopEmitLea(operands[1], :intptr)
    10521050
    10531051        when "baddio"
     
    10731071
    10741072        when "baddps"
    1075             cloopEmitOpAndBranch(operands, "+", :int, "< 0")
     1073            cloopEmitOpAndBranch(operands, "+", :intptr, "< 0")
    10761074        when "baddpz"
    1077             cloopEmitOpAndBranch(operands, "+", :int, "== 0")
     1075            cloopEmitOpAndBranch(operands, "+", :intptr, "== 0")
    10781076        when "baddpnz"
    1079             cloopEmitOpAndBranch(operands, "+", :int, "!= 0")
     1077            cloopEmitOpAndBranch(operands, "+", :intptr, "!= 0")
    10801078
    10811079        when "bsubis"
Note: See TracChangeset for help on using the changeset viewer.