// vim: set syntax=asm :
{% from "zmm_ops.j2" import scalar %}

{{ scalar("scalar_min", "vminps", from, to) }}
{{ scalar("scalar_max", "vmaxps", from, to) }}
{{ scalar("scalar_add", "vaddps", from, to) }}
{{ scalar("scalar_mul", "vmulps", from, to) }}
{{ scalar("scalar_sub", "vsubps", from, to) }}
{{ scalar("scalar_sub_flipped", "vsubps", from, to, flipped=true) }}

{{L}}leaky_relu:
    // can only use zmm12 to zmm15
    // ymm15 <- alpha
    vbroadcastss    zmm15, dword ptr [rdi + 8]
    // ymm14 <- all zero
    vpxorq          zmm14, zmm14, zmm14

    {% for reg in range(from, to + 1) %}
        vcmpps      k1, zmm{{reg}}, zmm14, 1 // 1 means LT
        // ymm12 <- alpha * x if < 0
        vmulps      zmm{{reg}} {k1}, zmm{{reg}}, zmm15
    {% endfor %}
    // select muled of orginal

    jmp    {{L}}non_linear_loop

{{L}}q_scale:
{{L}}q_shl:
{{L}}q_shr:
    jmp {{L}}unsupported
