instruction.short4.inc

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

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

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

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

; <fold conversion>
    if(used inst$s4tob4) ; <fold >
        inst s4tob4
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpand   xmm0, xmm0, [s8.00]
                    vpxor   xmm1, xmm0, xmm0
                    vpackuswb xmm0, xmm0, xmm1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_BYTE4
        end_inst
    end if ; </fold>

    if(used inst$s4tos) ; <fold >
        inst s4tos
                    overify TAG_SHORT4
                    movsx   eax, word[rsp]
                    vmovd   xmm0, eax
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT
        end_inst
    end if ; </fold>

    if(used inst$s4tos2) ; <fold >
        inst s4tos2
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpand   xmm0, xmm0, [s8.03]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_SHORT2
        end_inst
    end if ; </fold>

    if(used inst$s4tos8) ; <fold >
        inst s4tos8
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpand   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_SHORT8
        end_inst
    end if ; </fold>

    if(used inst$s4toi4) ; <fold >
        inst s4toi4
                    overify TAG_SHORT4
                    vpmovsxwd xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4tol4) ; <fold >
        inst s4tol4
                    overify TAG_SHORT4
                    push1
                    vpmovsxwq ymm0, [rsp+$10]
                    vmovdqu yword[rsp], ymm0
                    set     TAG_LONG4
        end_inst
    end if ; </fold>
; </fold>

; <fold relation>
    if(used inst$s4se) ; <fold >
        inst s4se
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovsxwd xmm0, [rsp+$10]
                    vpmovsxwd xmm1, [rsp+$00]
                    vpcmpeqd xmm0, xmm0, xmm1
                    vmovmskps eax, xmm0
                    cmp     eax, $0f
                    sete    al
                    movsx   eax, al
                    vmovd   xmm0, eax
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT
        end_inst
    end if ; </fold>

    if(used inst$s4sne) ; <fold >
        inst s4sne
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovsxwd xmm0, [rsp+$10]
                    vpmovsxwd xmm1, [rsp+$00]
                    vpcmpeqd xmm0, xmm0, xmm1
                    vmovmskps eax, xmm0
                    cmp     eax, $0f
                    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$s4not) ; <fold >
        inst s4not
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpxor   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp], xmm0
        end_inst
    end if ; </fold>

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

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

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

; <fold scalar>
    if(used inst$s4sneg) ; <fold >
        inst s4sneg
                    overify TAG_SHORT4
                    vpmovsxwd xmm0, [rsp]
                    vpxor   xmm1, xmm0, xmm0
                    vpsubd  xmm0, xmm1, xmm0
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4smul) ; <fold >
        inst s4smul
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovsxwd xmm0, [rsp+$10]
                    vpmovsxwd xmm1, [rsp+$00]
                    vshufps xmm4, xmm1, xmm1, $e4
                    vshufps xmm5, xmm4, xmm4, $b1
                    vshufps xmm6, xmm4, xmm4, $4e
                    vshufps xmm7, xmm4, xmm4, $1b
                    vpmulld xmm4, xmm4, [i4.q0]
                    vpmulld xmm5, xmm5, [i4.q1]
                    vpmulld xmm6, xmm6, [i4.q2]
                    vpmulld xmm7, xmm7, [i4.q3]
                    vpmulld xmm3, xmm0, xmm7
                    vpmulld xmm2, xmm0, xmm6
                    vpmulld xmm1, xmm0, xmm5
                    vpmulld xmm0, xmm0, xmm4
                    vphaddd xmm0, xmm0, xmm1
                    vphaddd xmm1, xmm2, xmm3
                    vphaddd xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4sadd) ; <fold >
        inst s4sadd
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovsxwd xmm0, [rsp+$10]
                    vpmovsxwd xmm1, [rsp+$00]
                    vpaddd  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4ssub) ; <fold >
        inst s4ssub
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovsxwd xmm0, [rsp+$10]
                    vpmovsxwd xmm1, [rsp+$00]
                    vpsubd  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4ssar) ; <fold >
        inst s4ssar
                    overify TAG_SHORT4, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vpmovsxwd xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrad  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4ssal) ; <fold >
        inst s4ssal
                    overify TAG_SHORT4, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vpmovsxwd xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpslld  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4sshr) ; <fold >
        inst s4sshr
                    overify TAG_SHORT4, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vpmovsxwd xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrld  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT4
        end_inst
    end if ; </fold>
; </fold>

; <fold vector>
    if(used inst$s4vpack) ; <fold >
        inst s4vpack
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpxor   xmm1, xmm0, xmm0
                    vpackuswb xmm0, xmm0, xmm1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_BYTE4
        end_inst
    end if ; </fold>

    if(used inst$s4vunpckl) ; <fold >
        inst s4vunpckl
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpxor   xmm1, xmm0, xmm0
                    vpunpcklwd xmm0, xmm0, xmm1
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4vunpcku) ; <fold >
        inst s4vunpcku
                    overify TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpxor   xmm1, xmm0, xmm0
                    vpunpcklwd xmm0, xmm1, xmm0
                    vmovdqa xword[rsp], xmm0
                    set     TAG_INT4
        end_inst
    end if ; </fold>

    if(used inst$s4vneg) ; <fold >
        inst s4vneg
                    overify TAG_SHORT4
                    vpxor   xmm0, xmm0, xmm0
                    vpsubw  xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp], xmm0
        end_inst
    end if ; </fold>

    if(used inst$s4vmul) ; <fold >
        inst s4vmul
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpmullw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vadd) ; <fold >
        inst s4vadd
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpaddw  xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vsub) ; <fold >
        inst s4vsub
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpsubw  xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vsar) ; <fold >
        inst s4vsar
                    overify TAG_SHORT4, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vmovdqa xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsraw  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vsal) ; <fold >
        inst s4vsal
                    overify TAG_SHORT4, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vmovdqa xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsllw  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vshr) ; <fold >
        inst s4vshr
                    overify TAG_SHORT4, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vmovdqa xmm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrlw  xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vg) ; <fold >
        inst s4vg
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpcmpgtw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vge) ; <fold >
        inst s4vge
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpcmpgtw xmm0, xmm0, [rsp+$10]
                    vpxor   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vl) ; <fold >
        inst s4vl
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp]
                    vpcmpgtw xmm0, xmm0, [rsp+$10]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vle) ; <fold >
        inst s4vle
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpcmpgtw xmm0, xmm0, [rsp]
                    vpxor   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4ve) ; <fold >
        inst s4ve
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpcmpeqw xmm0, xmm0, [rsp]
                    vpand   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vne) ; <fold >
        inst s4vne
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpcmpeqw xmm0, xmm0, [rsp]
                    vpxor   xmm0, xmm0, [s8.00]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vmuls) ; <fold >
        inst s4vmuls
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovsxwd xmm0, [rsp+$10]
                    vpmovsxwd xmm1, [rsp+$00]
                    vpmulld xmm0, xmm0, xmm1
                    vpaddd  xmm0, xmm0, [i8.05]
                    vpsrad  xmm0, xmm0, $0f
                    vpackssdw xmm0, xmm0, xmm0
                    vpand   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vadds) ; <fold >
        inst s4vadds
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpaddsw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vsubs) ; <fold >
        inst s4vsubs
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpsubsw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vmulu) ; <fold >
        inst s4vmulu
                    overify TAG_SHORT4, TAG_SHORT4
                    vpmovzxwd xmm0, [rsp+$10]
                    vpmovzxwd xmm1, [rsp+$00]
                    vpmulld xmm0, xmm0, xmm1
                    vpaddd  xmm0, xmm0, [i8.02]
                    vpsrld  xmm0, xmm0, $10
                    vpackusdw xmm0, xmm0, xmm0
                    vpand   xmm0, xmm0, [s8.02]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vaddu) ; <fold >
        inst s4vaddu
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpaddusw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

    if(used inst$s4vsubu) ; <fold >
        inst s4vsubu
                    overify TAG_SHORT4, TAG_SHORT4
                    vmovdqa xmm0, [rsp+$10]
                    vpsubusw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>
; </fold>