instruction.int2.inc

Переключить прокрутку окна
Загрузить этот исходный код

;
 ;  Исходный код среды исполнения ПВТ-ОО.
 ;
 ;  Этот исходный код является частью проекта ПВТ-ОО.
 ;
 ;  Copyright © 2021 Малик Разработчик
 ;
 ;  Это свободная программа: вы можете перераспространять её и/или
 ;  изменять её на условиях Меньшей Стандартной общественной лицензии GNU в том виде,
 ;  в каком она была опубликована Фондом свободного программного обеспечения;
 ;  либо версии 3 лицензии, либо (по вашему выбору) любой более поздней версии.
 ;
 ;  Эта программа распространяется в надежде, что она может быть полезна,
 ;  но БЕЗО ВСЯКИХ ГАРАНТИЙ; даже без неявной гарантии ТОВАРНОГО ВИДА
 ;  или ПРИГОДНОСТИ ДЛЯ ОПРЕДЕЛЁННЫХ ЦЕЛЕЙ. Подробнее см. в Меньшей Стандартной
 ;  общественной лицензии GNU.
 ;
 ;  Вы должны были получить копию Меньшей Стандартной общественной лицензии GNU
 ;  вместе с этой программой. Если это не так, см.
 ;  <http://www.gnu.org/licenses/>.
;

; <fold push/pop/peek>
    if(used inst$i2push) ; <fold >
        inst i2push ; (value in xmm0)
                    push1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT2
        end_inst
    end if ; </fold>

    if(used inst$i2pop) ; <fold >
        inst i2pop ; (): value in xmm0
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    pop1set
        end_inst
    end if ; </fold>
; </fold>

; <fold conversion>
    if(used inst$i2tob2) ; <fold >
        inst i2tob2
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vpand   xmm0, xmm0, [i8.03]
                    vpxor   xmm1, xmm0, xmm0
                    vpackusdw xmm0, xmm0, xmm1
                    vpackuswb xmm0, xmm0, xmm1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_BYTE2
        end_inst
    end if ; </fold>

    if(used inst$i2tos2) ; <fold >
        inst i2tos2
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vpand   xmm0, xmm0, [i8.02]
                    vpxor   xmm1, xmm0, xmm0
                    vpackusdw xmm0, xmm0, xmm1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_SHORT2
        end_inst
    end if ; </fold>

    if(used inst$i2toi) ; <fold >
        inst i2toi
                    overify TAG_INT2
                    vmovd   xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT
        end_inst
    end if ; </fold>

    if(used inst$i2toi4) ; <fold >
        inst i2toi4
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$i2toi8) ; <fold >
        inst i2toi8
                    overify TAG_INT2
                    push1
                    vmovq   xmm0, [rsp+$10]
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$i2tol2) ; <fold >
        inst i2tol2
                    overify TAG_INT2
                    vpmovsxdq xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_LONG2
        end_inst
    end if ; </fold>

    if(used inst$i2tof2) ; <fold >
        inst i2tof2
                    overify TAG_INT2
                    vcvtdq2ps xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_FLOAT2
        end_inst
    end if ; </fold>

    if(used inst$i2tod2) ; <fold >
        inst i2tod2
                    overify TAG_INT2
                    vcvtdq2pd xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_DOUBLE2
        end_inst
    end if ; </fold>
; </fold>

; <fold relation>
    if(used inst$i2se) ; <fold >
        inst i2se
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpcmpeqd xmm0, xmm0, [rsp]
                    vmovmskps eax, xmm0
                    and     eax, $03
                    cmp     eax, $03
                    sete    al
                    movsx   eax, al
                    vmovd   xmm0, eax
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT
        end_inst
    end if ; </fold>

    if(used inst$i2sne) ; <fold >
        inst i2sne
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vmovq   xmm1, [rsp+$00]
                    vpcmpeqd xmm0, xmm0, xmm1
                    vmovmskps eax, xmm0
                    and     eax, $03
                    cmp     eax, $03
                    setne   al
                    movsx   eax, al
                    vmovd   xmm0, eax
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT
        end_inst
    end if ; </fold>
; </fold>

; <fold bitwise>
    if(used inst$i2not) ; <fold >
        inst i2not
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vpxor   xmm0, xmm0, [i8.04]
                    vmovdqa xword[rsp], xmm0
        end_inst
    end if ; </fold>

    if(used inst$i2and) ; <fold >
        inst i2and
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpand   xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2or) ; <fold >
        inst i2or
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpor    xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2xor) ; <fold >
        inst i2xor
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpxor   xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>
; </fold>

; <fold scalar>
    if(used inst$i2sneg | used inst$i2vneg) ; <fold >
        inst i2sneg, i2vneg
                    overify TAG_INT2
                    vpxor   xmm0, xmm0, xmm0
                    vpsubd  xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
        end_inst
    end if ; </fold>

    if(used inst$i2smul) ; <fold >
        inst i2smul
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vmovq   xmm1, [rsp+$00]
                    vshufps xmm2, xmm1, xmm1, $e4
                    vshufps xmm3, xmm2, xmm2, $e1
                    vpmulld xmm2, xmm2, [i2.c0]
                    vpmulld xmm1, xmm0, xmm3
                    vpmulld xmm0, xmm0, xmm2
                    vphaddd xmm0, xmm0, xmm1
                    vshufps xmm0, xmm0, xmm0, $d8
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2sadd | used inst$i2vadd) ; <fold >
        inst i2sadd, i2vadd
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpaddd  xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2ssub | used inst$i2vsub) ; <fold >
        inst i2ssub, i2vsub
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpsubd  xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2ssar | used inst$i2vsar) ; <fold >
        inst i2ssar, i2vsar
                    overify TAG_INT2, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vmovq   xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrad  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2ssal | used inst$i2vsal) ; <fold >
        inst i2ssal, i2vsal
                    overify TAG_INT2, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vmovq   xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpslld  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2sshr | used inst$i2vshr) ; <fold >
        inst i2sshr, i2vshr
                    overify TAG_INT2, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vmovq   xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrld  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>
; </fold>

; <fold vector>
    if(used inst$i2vpack) ; <fold >
        inst i2vpack
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vpxor   xmm1, xmm0, xmm0
                    vpackusdw xmm0, xmm0, xmm1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_SHORT2
        end_inst
    end if ; </fold>

    if(used inst$i2vunpckl) ; <fold >
        inst i2vunpckl
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vshufps xmm0, xmm0, xmm0, $d8
                    vmovdqa xword[rsp], xmm0
                    set     TAG_LONG2
        end_inst
    end if ; </fold>

    if(used inst$i2vunpcku) ; <fold >
        inst i2vunpcku
                    overify TAG_INT2
                    vmovq   xmm0, [rsp]
                    vshufps xmm0, xmm0, xmm0, $72
                    vmovdqa xword[rsp], xmm0
                    set     TAG_LONG2
        end_inst
    end if ; </fold>

    if(used inst$i2vmul) ; <fold >
        inst i2vmul
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpmulld xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2vg) ; <fold >
        inst i2vg
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpcmpgtd xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2vge) ; <fold >
        inst i2vge
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp]
                    vpcmpgtd xmm0, xmm0, [rsp+$10]
                    vpxor   xmm0, xmm0, [i8.04]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2vl) ; <fold >
        inst i2vl
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp]
                    vpcmpgtd xmm0, xmm0, [rsp+$10]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2vle) ; <fold >
        inst i2vle
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpcmpgtd xmm0, xmm0, [rsp]
                    vpxor   xmm0, xmm0, [i8.04]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2ve) ; <fold >
        inst i2ve
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpcmpeqd xmm0, xmm0, [rsp]
                    vpand   xmm0, xmm0, [i8.04]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$i2vne) ; <fold >
        inst i2vne
                    overify TAG_INT2, TAG_INT2
                    vmovq   xmm0, [rsp+$10]
                    vpcmpeqd xmm0, xmm0, [rsp]
                    vpxor   xmm0, xmm0, [i8.01]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>
; </fold>