Ignore:
Timestamp:
Apr 5, 2013, 1:41:01 PM (12 years ago)
Author:
[email protected]
Message:

Unreviewed, rolling out http://trac.webkit.org/changeset/147729

It's causing a bunch of breakage on some more strict compilers:
<inline asm>:1267:2: error: ambiguous instructions require an explicit suffix (could be 'ficomps', or 'ficompl')

  • offlineasm/x86.rb:
File:
1 edited

Legend:

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

    r147729 r147794  
    3535end
    3636
    37 def useX87
    38     case $activeBackend
    39     when "X86"
    40         true
    41     when "X86_64"
    42         false
    43     else
    44         raise "bad value for $activeBackend: #{$activeBackend}"
    45     end
    46 end
    47 
    4837class SpecialRegister < NoChildren
    4938    def x86Operand(kind)
     
    267256    def x86Operand(kind)
    268257        raise unless kind == :double
    269         raise if useX87
    270258        case name
    271259        when "ft0", "fa0", "fr"
     
    281269        when "ft5"
    282270            "%xmm5"
    283         else
    284             raise "Bad register #{name} for X86 at #{codeOriginString}"
    285         end
    286     end
    287     def x87Operand(offset)
    288         raise unless useX87
    289         raise unless offset == 0 or offset == 1
    290         case name
    291         when "ft0", "fa0", "fr"
    292             "%st(#{0 + offset})"
    293         when "ft1", "fa1"
    294             "%st(#{1 + offset})"
    295         when "ft2", "fa2"
    296             "%st(#{2 + offset})"
    297         when "ft3", "fa3"
    298             "%st(#{3 + offset})"
    299         when "ft4"
    300             "%st(#{4 + offset})"
    301         when "ft5"
    302             "%st(#{5 + offset})"
    303271        else
    304272            raise "Bad register #{name} for X86 at #{codeOriginString}"
     
    455423            isX64 ? "q" : raise
    456424        when :double
    457             not useX87 ? "sd" : raise
     425            "sd"
    458426        else
    459427            raise
     
    511479   
    512480    def handleX86DoubleBranch(branchOpcode, mode)
    513         if useX87
    514             case mode
    515             when :normal
    516                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    517                 $asm.puts "fucomip #{operands[1].x87Operand(1)}"
    518             when :reverse
    519                 $asm.puts "fld #{operands[1].x87Operand(0)}"
    520                 $asm.puts "fucomip #{operands[0].x87Operand(1)}"
    521             else
    522                 raise mode.inspect
    523             end
    524         else
    525             case mode
    526             when :normal
    527                 $asm.puts "ucomisd #{operands[1].x86Operand(:double)}, #{operands[0].x86Operand(:double)}"
    528             when :reverse
    529                 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    530             else
    531                 raise mode.inspect
    532             end
     481        case mode
     482        when :normal
     483            $asm.puts "ucomisd #{operands[1].x86Operand(:double)}, #{operands[0].x86Operand(:double)}"
     484        when :reverse
     485            $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
     486        else
     487            raise mode.inspect
    533488        end
    534489        $asm.puts "#{branchOpcode} #{operands[2].asmLabel}"
     
    795750        when "storeb"
    796751            $asm.puts "movb #{x86Operands(:byte, :byte)}"
    797         when "loadd"
    798             if useX87
    799                 $asm.puts "fldl #{operands[0].x86Operand(:double)}"
    800                 $asm.puts "fstp #{operands[1].x87Operand(1)}"
    801             else
    802                 $asm.puts "movsd #{x86Operands(:double, :double)}"
    803             end
    804         when "moved"
    805             if useX87
    806                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    807                 $asm.puts "fstp #{operands[0].x87Operand(1)}"
    808             else
    809                 $asm.puts "movsd #{x86Operands(:double, :double)}"
    810             end
    811         when "stored"
    812             if useX87
    813                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    814                 $asm.puts "fstpl #{operands[1].x86Operand(:double)}"
    815             else
    816                 $asm.puts "movsd #{x86Operands(:double, :double)}"
    817             end
     752        when "loadd", "moved", "stored"
     753            $asm.puts "movsd #{x86Operands(:double, :double)}"
    818754        when "addd"
    819             if useX87
    820                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    821                 $asm.puts "faddp %st, #{operands[1].x87Operand(1)}"
    822             else
    823                 $asm.puts "addsd #{x86Operands(:double, :double)}"
    824             end
     755            $asm.puts "addsd #{x86Operands(:double, :double)}"
    825756        when "divd"
    826             if useX87
    827                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    828                 $asm.puts "fdivrp %st, #{operands[1].x87Operand(1)}"
    829             else
    830                 $asm.puts "divsd #{x86Operands(:double, :double)}"
    831             end
     757            $asm.puts "divsd #{x86Operands(:double, :double)}"
    832758        when "subd"
    833             if useX87
    834                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    835                 $asm.puts "fsubrp %st, #{operands[1].x87Operand(1)}"
    836             else
    837                 $asm.puts "subsd #{x86Operands(:double, :double)}"
    838             end
     759            $asm.puts "subsd #{x86Operands(:double, :double)}"
    839760        when "muld"
    840             if useX87
    841                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    842                 $asm.puts "fmulp %st, #{operands[1].x87Operand(1)}"
    843             else
    844                 $asm.puts "mulsd #{x86Operands(:double, :double)}"
    845             end
     761            $asm.puts "mulsd #{x86Operands(:double, :double)}"
    846762        when "sqrtd"
    847             if useX87
    848                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    849                 $asm.puts "fsqrtl"
    850                 $asm.puts "fstp #{operands[1].x87Operand(1)}"
    851             else
    852                 $asm.puts "sqrtsd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    853             end
     763            $asm.puts "sqrtsd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    854764        when "ci2d"
    855             if useX87
    856                 if isX64
    857                     $asm.puts "sub#{x86Suffix(:ptr)} $4, %rsp"
    858                     $asm.puts "movl #{operands[0].x86Operand(:int)}, 0(%rsp)"
    859                     $asm.puts "fildl 0(%rsp)"
    860                     $asm.puts "add#{x86Suffix(:ptr)} $4, %rsp"
    861                 else
    862                     $asm.puts "sub#{x86Suffix(:ptr)} $4, %esp"
    863                     $asm.puts "movl #{operands[0].x86Operand(:int)}, 0(%esp)"
    864                     $asm.puts "fildl 0(%esp)"
    865                     $asm.puts "add#{x86Suffix(:ptr)} $4, %esp"
    866                 end
    867                 $asm.puts "fstp #{operands[1].x87Operand(1)}"
    868             else
    869                 $asm.puts "cvtsi2sd #{operands[0].x86Operand(:int)}, #{operands[1].x86Operand(:double)}"
    870             end
     765            $asm.puts "cvtsi2sd #{operands[0].x86Operand(:int)}, #{operands[1].x86Operand(:double)}"
    871766        when "bdeq"
    872             if useX87
    873                 $asm.puts "fld #{operands[1].x87Operand(0)}"
    874                 $asm.puts "fucomip #{operands[0].x87Operand(1)}"
    875             else
    876                 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    877             end
     767            $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    878768            if operands[0] == operands[1]
    879769                # This is just a jump ordered, which is a jnp.
     
    898788            handleX86DoubleBranch("je", :normal)
    899789        when "bdnequn"
    900             if useX87
    901                 $asm.puts "fld #{operands[1].x87Operand(0)}"
    902                 $asm.puts "fucomip #{operands[0].x87Operand(1)}"
    903             else
    904                 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    905             end
     790            $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:double)}"
    906791            if operands[0] == operands[1]
    907792                # This is just a jump unordered, which is a jp.
     
    925810            handleX86DoubleBranch("jbe", :normal)
    926811        when "btd2i"
    927             # FIXME: unused and unimplemented for x87
    928             raise if useX87
    929812            $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
    930813            $asm.puts "cmpl $0x80000000 #{operands[1].x86Operand(:int)}"
    931814            $asm.puts "je #{operands[2].asmLabel}"
    932815        when "td2i"
    933             # FIXME: unused and unimplemented for x87
    934             raise if useX87
    935816            $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
    936817        when "bcd2i"
    937             if useX87
    938                 raise if isX64
    939                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    940                 $asm.puts "sub#{x86Suffix(:ptr)} $4, %esp"
    941                 $asm.puts "fistl 0(%esp)"
    942                 $asm.puts "ficomp 0(%esp)"
    943                 $asm.puts "popl #{operands[1].x86Operand(:int)}"
    944                 $asm.puts "jp #{operands[2].asmLabel}"
    945                 $asm.puts "jne #{operands[2].asmLabel}"
    946             else
    947                 $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
    948                 $asm.puts "testl #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}"
    949                 $asm.puts "je #{operands[2].asmLabel}"
    950                 $asm.puts "cvtsi2sd #{operands[1].x86Operand(:int)}, %xmm7"
    951                 $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, %xmm7"
    952                 $asm.puts "jp #{operands[2].asmLabel}"
    953                 $asm.puts "jne #{operands[2].asmLabel}"
    954             end
     818            $asm.puts "cvttsd2si #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
     819            $asm.puts "testl #{operands[1].x86Operand(:int)}, #{operands[1].x86Operand(:int)}"
     820            $asm.puts "je #{operands[2].asmLabel}"
     821            $asm.puts "cvtsi2sd #{operands[1].x86Operand(:int)}, %xmm7"
     822            $asm.puts "ucomisd #{operands[0].x86Operand(:double)}, %xmm7"
     823            $asm.puts "jp #{operands[2].asmLabel}"
     824            $asm.puts "jne #{operands[2].asmLabel}"
    955825        when "movdz"
    956             if useX87
    957                 $asm.puts "fldzl"
    958                 $asm.puts "fstp #{operands[0].x87Operand(1)}"
    959             else
    960                 $asm.puts "xorpd #{operands[0].x86Operand(:double)}, #{operands[0].x86Operand(:double)}"
    961             end
     826            $asm.puts "xorpd #{operands[0].x86Operand(:double)}, #{operands[0].x86Operand(:double)}"
    962827        when "pop"
    963828            $asm.puts "pop #{operands[0].x86Operand(:ptr)}"
     
    12531118            $asm.puts "idivl #{operands[0].x86Operand(:int)}"
    12541119        when "fii2d"
    1255             if useX87
    1256                 raise if isX64
    1257                 $asm.puts "sub#{x86Suffix(:ptr)} $8, %esp"
    1258                 $asm.puts "movl #{operands[0].x86Operand(:int)}, 0(%esp)"
    1259                 $asm.puts "movl #{operands[1].x86Operand(:int)}, 4(%esp)"
    1260                 $asm.puts "fldl 0(%esp)"
    1261                 $asm.puts "add#{x86Suffix(:ptr)} $8, %esp"
    1262                 $asm.puts "fstp #{operands[2].x87Operand(1)}"
    1263             else
    1264                 $asm.puts "movd #{operands[0].x86Operand(:int)}, #{operands[2].x86Operand(:double)}"
    1265                 $asm.puts "movd #{operands[1].x86Operand(:int)}, %xmm7"
    1266                 $asm.puts "psllq $32, %xmm7"
    1267                 $asm.puts "por %xmm7, #{operands[2].x86Operand(:double)}"
    1268             end
     1120            $asm.puts "movd #{operands[0].x86Operand(:int)}, #{operands[2].x86Operand(:double)}"
     1121            $asm.puts "movd #{operands[1].x86Operand(:int)}, %xmm7"
     1122            $asm.puts "psllq $32, %xmm7"
     1123            $asm.puts "por %xmm7, #{operands[2].x86Operand(:double)}"
    12691124        when "fd2ii"
    1270             if useX87
    1271                 raise if isX64
    1272                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    1273                 $asm.puts "sub#{x86Suffix(:ptr)} $8, %esp"
    1274                 $asm.puts "fstpl 0(%esp)"
    1275                 $asm.puts "movl 0(%esp), #{operands[1].x86Operand(:int)}"
    1276                 $asm.puts "movl 4(%esp), #{operands[2].x86Operand(:int)}"
    1277                 $asm.puts "add#{x86Suffix(:ptr)} $8, %esp"
    1278             else
    1279                 $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
    1280                 $asm.puts "movsd #{operands[0].x86Operand(:double)}, %xmm7"
    1281                 $asm.puts "psrlq $32, %xmm7"
    1282                 $asm.puts "movd %xmm7, #{operands[2].x86Operand(:int)}"
    1283             end
     1125            $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:int)}"
     1126            $asm.puts "movsd #{operands[0].x86Operand(:double)}, %xmm7"
     1127            $asm.puts "psrlq $32, %xmm7"
     1128            $asm.puts "movd %xmm7, #{operands[2].x86Operand(:int)}"
    12841129        when "fq2d"
    1285             if useX87
    1286                 raise unless isX64
    1287                 $asm.puts "push #{operands[0].x86Operand(:quad)}"
    1288                 $asm.puts "fldl 0(%rsp)"
    1289                 $asm.puts "add#{x86Suffix(:ptr)} $8, %rsp"
    1290                 $asm.puts "fstp #{operands[1].x87Operand(1)}"
    1291             else
    1292                 $asm.puts "movq #{operands[0].x86Operand(:quad)}, #{operands[1].x86Operand(:double)}"
    1293             end
     1130            $asm.puts "movd #{operands[0].x86Operand(:quad)}, #{operands[1].x86Operand(:double)}"
    12941131        when "fd2q"
    1295             if useX87
    1296                 raise unless isX64
    1297                 $asm.puts "fld #{operands[0].x87Operand(0)}"
    1298                 $asm.puts "sub#{x86Suffix(:ptr)} $8, %rsp"
    1299                 $asm.puts "fstpl 0(%rsp)"
    1300                 $asm.puts "pop #{operands[1].x86Operand(:quad)}"
    1301             else
    1302                 $asm.puts "movq #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:quad)}"
    1303             end
     1132            $asm.puts "movd #{operands[0].x86Operand(:double)}, #{operands[1].x86Operand(:quad)}"
    13041133        when "bo"
    13051134            $asm.puts "jo #{operands[0].asmLabel}"
Note: See TracChangeset for help on using the changeset viewer.