1   /* Copyright (C) 2008 The Android Open Source Project
2    *
3    * Licensed under the Apache License, Version 2.0 (the "License");
4    * you may not use this file except in compliance with the License.
5    * You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software
10    * distributed under the License is distributed on an "AS IS" BASIS,
11    * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12    * See the License for the specific language governing permissions and
13    * limitations under the License.
14    */
15
16   /*
17    * File: OP_CMPL_FLOAT.S
18    *
19    * Code: Provides a "nan" variable to specify the return value for
20    *       NaN. Provides a variable "sod" which appends a "s" or a "d"
21    *       to the move and comparison instructions, depending on if we
22    *       are working with a float or a double. For instructions
23    *       cmpx-float and cmpx-double, the x will be eiher a g or a l
24    *       to specify positive or negative bias for NaN.
25    *
26    * For: cmpg-double, dmpg-float, cmpl-double, cmpl-float
27    *
28    * Description: Perform the indicated floating point or long comparison,
29    *              storing 0 if the two arguments are equal, 1 if the second
30    *              argument is larger, or -1 if the first argument is larger.
31    *
32    * Format: AA|op CC|BB (23x)
33    *
34    * Syntax: op vAA, vBB, vCC
35    */
36
37%default { "nan":"$0xFFFFFFFF" , "sod":"s" }
38
39    FETCH_BB    1, %ecx                 # %ecx<- BB
40    FETCH_CC    1, %edx                 # %edx<- CC
41
42    fld$sod     (rFP, %edx, 4)
43    fld$sod     (rFP, %ecx, 4)
44
45    fucompp
46    fnstsw      %ax
47    sahf
48
49    FFETCH_ADV  2, %eax                 # %eax<- next instruction hi; fetch, advance
50    ja          .L${opcode}_greater
51    jp          .L${opcode}_finalNan
52    jz          .L${opcode}_final
53
54.L${opcode}_less:
55    movl        $$0xFFFFFFFF, (rFP, rINST, 4) # vAA<- less than
56    FGETOP_JMP  2, %eax                 # jump to next instruction; getop, jmp
57
58%break
59.L${opcode}_greater:
60    movl        $$0x1, (rFP, rINST, 4)  # vAA<- greater than
61    FGETOP_JMP  2, %eax                 # jump to next instruction; getop, jmp
62
63.L${opcode}_final:
64    movl        $$0x0, (rFP, rINST, 4)  # vAA<- equal
65    FGETOP_JMP  2, %eax                 # jump to next instruction; getop, jmp
66
67.L${opcode}_finalNan:
68    movl        $nan, (rFP, rINST, 4)   # vAA<- NaN
69    FGETOP_JMP  2, %eax                 # jump to next instruction; getop, jmp
70