Using imm8 through inline assembler
anonymous via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Tue Oct 28 15:18:52 PDT 2014
On Tuesday, 28 October 2014 at 21:05:15 UTC, Etienne wrote:
> I'm trying to write (in DMD) the assembler that handles the
> function :
>
> __m256i _mm256_permute4x64_epi64(__m256i a, in int M);
>
> This translates to vpermq
>
> The closest thing I could find in DMD assembly is VPERMILPS,
> which is called with:
>
> asm { vpermilps YMM0, YMM1, IMM8; }
>
> However, I cannot find out how to make IMM8 with `in int M`. I
> can convert int -> short[4] -> ubyte, but I can't move it into
> imm8
>
> asm { mov imm8, ub; } <-- Fails.
>
>
> Does anyone have an idea of what this is and how to define it?
Disclaimer: I only know a little basic X86 assembler, and I'm
just going of the first google result for "vpermilps" [1].
"imm8" is not a register. "imm" stands for "immediate", i.e. a
constant, hard-coded value. E.g.:
asm { vpermilps YMM0, YMM1, 0 /* no idea what would be a
meaningful value */; }
There are variants of vpermilps that work on three registers. The
third register is a XMM/YMM register, too, then. E.g.:
asm { vpermilps YMM0, YMM1, YMM2; }
I think my CPU doesn't have AVX, so I can't test anything beyond
compiling. When running all I get is "Illegal instruction (core
dumped)".
[1] http://www.felixcloutier.com/x86/VPERMILPS.html
More information about the Digitalmars-d-learn
mailing list