instruction.short8.inc

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

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

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

    if(used inst$s8pop) ; <fold >
        inst s8pop ; (): value in xmm0
                    overify TAG_SHORT8
                    vmovdqa xmm0, [rsp]
                    pop1set
        end_inst
    end if ; </fold>
; </fold>

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

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

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

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

    if(used inst$s8toi8) ; <fold >
        inst s8toi8
                    overify TAG_SHORT8
                    push1
                    vpmovsxwd ymm0, [rsp+$10]
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8tol8) ; <fold >
        inst s8tol8
                    overify TAG_SHORT8
                    push3
                    vpmovsxwq zmm0, [rsp+$30]
                    vmovdqu64 zword[rsp], zmm0
                    set     TAG_LONG8
        end_inst
    end if ; </fold>
; </fold>

; <fold relation>
    if(used inst$s8se) ; <fold >
        inst s8se
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovsxwd ymm0, [rsp+$10]
                    vpmovsxwd ymm1, [rsp+$00]
                    vpcmpeqd ymm0, ymm0, ymm1
                    vmovmskps eax, ymm0
                    cmp     eax, $ff
                    sete    al
                    movsx   eax, al
                    vmovd   xmm0, eax
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set TAG_INT
        end_inst
    end if ; </fold>

    if(used inst$s8sne) ; <fold >
        inst s8sne
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovsxwd ymm0, [rsp+$10]
                    vpmovsxwd ymm1, [rsp+$00]
                    vpcmpeqd ymm0, ymm0, ymm1
                    vmovmskps eax, ymm0
                    cmp     eax, $ff
                    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$s8not) ; <fold >
        inst s8not
                    overify TAG_SHORT8
                    vmovdqa xmm0, [rsp]
                    vpxor   xmm0, xmm0, [s8.01]
                    vmovdqa xword[rsp], xmm0
        end_inst
    end if ; </fold>

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

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

    if(used inst$s8xor) ; <fold >
        inst s8xor
                    overify TAG_SHORT8, TAG_SHORT8
                    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$s8sneg) ; <fold >
        inst s8sneg
                    overify TAG_SHORT8
                    push1
                    vpmovsxwd ymm0, [rsp+$10]
                    vpxor   ymm1, ymm0, ymm0
                    vpsubd  ymm0, ymm1, ymm0
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8smul) ; <fold >
        inst s8smul
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovsxwd ymm0, [rsp+$10]
                    vpmovsxwd ymm1, [rsp+$00]
                    vmovdqa ymm8, ymm1
                    vextracti128 xmm12, ymm8, $01
                    vinserti128 ymm12, ymm12, xmm8, $01
                    vshufps ymm9, ymm8, ymm8, $b1
                    vshufps ymm10, ymm8, ymm8, $4e
                    vshufps ymm11, ymm8, ymm8, $1b
                    vshufps ymm13, ymm12, ymm12, $b1
                    vshufps ymm14, ymm12, ymm12, $4e
                    vshufps ymm15, ymm12, ymm12, $1b
                    vpmulld ymm8, ymm8, [i8.o0]
                    vpmulld ymm9, ymm9, [i8.o1]
                    vpmulld ymm10, ymm10, [i8.o2]
                    vpmulld ymm11, ymm11, [i8.o3]
                    vpmulld ymm12, ymm12, [i8.o4]
                    vpmulld ymm13, ymm13, [i8.o5]
                    vpmulld ymm14, ymm14, [i8.o6]
                    vpmulld ymm15, ymm15, [i8.o7]
                    vpmulld ymm7, ymm0, ymm15
                    vpmulld ymm6, ymm0, ymm14
                    vpmulld ymm5, ymm0, ymm13
                    vpmulld ymm4, ymm0, ymm12
                    vpmulld ymm3, ymm0, ymm11
                    vpmulld ymm2, ymm0, ymm10
                    vpmulld ymm1, ymm0, ymm9
                    vpmulld ymm0, ymm0, ymm8
                    vphaddd ymm0, ymm0, ymm1
                    vphaddd ymm1, ymm2, ymm3
                    vphaddd ymm2, ymm4, ymm5
                    vphaddd ymm3, ymm6, ymm7
                    vphaddd ymm0, ymm0, ymm1
                    vphaddd ymm1, ymm2, ymm3
                    vextracti128 xmm2, ymm0, $01
                    vextracti128 xmm3, ymm1, $01
                    vpaddd  xmm0, xmm0, xmm2
                    vpaddd  xmm1, xmm1, xmm3
                    vinserti128 ymm0, ymm0, xmm1, $01
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8sadd) ; <fold >
        inst s8sadd
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovsxwd ymm0, [rsp+$10]
                    vpmovsxwd ymm1, [rsp+$00]
                    vpaddd  ymm0, ymm0, ymm1
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8ssub) ; <fold >
        inst s8ssub
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovsxwd ymm0, [rsp+$10]
                    vpmovsxwd ymm1, [rsp+$00]
                    vpsubd  ymm0, ymm0, ymm1
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8ssar) ; <fold >
        inst s8ssar
                    overify TAG_SHORT8, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vpmovsxwd ymm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrad  ymm0, ymm0, xmm1
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8ssal) ; <fold >
        inst s8ssal
                    overify TAG_SHORT8, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vpmovsxwd ymm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpslld  ymm0, ymm0, xmm1
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8sshr) ; <fold >
        inst s8sshr
                    overify TAG_SHORT8, TAG_INT
                    mov     ecx, [rsp]
                    and     ecx, $1f
                    vpmovsxwd ymm0, [rsp+$10]
                    vmovd   xmm1, ecx
                    vpsrld  ymm0, ymm0, xmm1
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>
; </fold>

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

    if(used inst$s8vunpckl) ; <fold >
        inst s8vunpckl
                    overify TAG_SHORT8
                    push1
                    vpmovzxwd ymm0, [rsp+$10]
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

    if(used inst$s8vunpcku) ; <fold >
        inst s8vunpcku
                    overify TAG_SHORT8
                    push1
                    vpmovzxwd ymm0, [rsp+$10]
                    vpslld  ymm0, ymm0, $10
                    vmovdqu yword[rsp], ymm0
                    set     TAG_INT8
        end_inst
    end if ; </fold>

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

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

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

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

    if(used inst$s8vsar) ; <fold >
        inst s8vsar
                    overify TAG_SHORT8, 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$s8vsal) ; <fold >
        inst s8vsal
                    overify TAG_SHORT8, 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$s8vshr) ; <fold >
        inst s8vshr
                    overify TAG_SHORT8, 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$s8vg) ; <fold >
        inst s8vg
                    overify TAG_SHORT8, TAG_SHORT8
                    vmovdqa xmm0, [rsp+$10]
                    vpcmpgtw xmm0, xmm0, [rsp]
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

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

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

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

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

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

    if(used inst$s8vmuls) ; <fold >
        inst s8vmuls
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovsxwd ymm0, [rsp+$10]
                    vpmovsxwd ymm1, [rsp+$00]
                    vpmulld ymm0, ymm0, ymm1
                    vpaddd  ymm0, ymm0, [i8.05]
                    vpsrad  ymm0, ymm0, $0f
                    vextracti128 xmm1, ymm0, $01
                    vpackssdw xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

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

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

    if(used inst$s8vmulu) ; <fold >
        inst s8vmulu
                    overify TAG_SHORT8, TAG_SHORT8
                    vpmovzxwd ymm0, [rsp+$10]
                    vpmovzxwd ymm1, [rsp+$00]
                    vpmulld ymm0, ymm0, ymm1
                    vpaddd  ymm0, ymm0, [i8.02]
                    vpsrld  ymm0, ymm0, $10
                    vextracti128 xmm1, ymm0, $01
                    vpackusdw xmm0, xmm0, xmm1
                    vmovdqa xword[rsp+$10], xmm0
                    pop1set
        end_inst
    end if ; </fold>

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

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