Files
cosmopolitan/libc/nexgen32e/macros.inc
Justine Tunney ea0b5d9d1c Get Cosmopolitan into releasable state
A new rollup tool now exists for flattening out the headers in a way
that works better for our purposes than cpp. A lot of the API clutter
has been removed. APIs that aren't a sure thing in terms of general
recommendation are now marked internal.

There's now a smoke test for the amalgamation archive and gigantic
header file. So we can now guarantee you can use this project on the
easiest difficulty setting without the gigantic repository.

A website is being created, which is currently a work in progress:
https://justine.storage.googleapis.com/cosmopolitan/index.html
2020-11-25 08:19:00 -08:00

72 lines
1.5 KiB
PHP

#include "libc/nexgen32e/x86feature.h"
#include "libc/macros.h"
/ Broadcast byte literal to vector, e.g.
/
/ # xmm0=0x12121212121212121212121212121212
/ .bcblit $0x12,%al,%eax,%xmm0
/
/ @param reg and regSI need to be the same register
.macro .bcblit lit:req reg:req regSI:req xmm:req
mov \lit,\reg
movd \regSI,\xmm
pbroadcastb \xmm
.endm
/ Broadcast word literal to vector, e.g.
/
/ # xmm0=0x01230123012301230123012301230123
/ .bcwlit $0x123,%ax,%eax,%xmm0
/
/ @param reg and regSI need to be the same register
.macro .bcwlit lit:req reg:req regSI:req xmm:req
mov \lit,\reg
movd \regSI,\xmm
pbroadcastw \xmm
.endm
/ Broadcast int16 from register to vector.
.macro .bcwreg regSI:req xmm:req
movd \regSI,\xmm
pbroadcastw \xmm
.endm
/ Sets all bytes in XMM register to first byte, e.g.
/
/ mov $0x11,%eax
/ movd %eax,%xmm0
/ pbroadcastb %xmm0
/
/ 11000000000000000000000000000000
/ 11111111111111111111111111111111
/
/ @param xmm can be %xmm0,%xmm1,etc.
.macro pbroadcastb xmm:req
#if X86_NEED(AVX2)
vpbroadcastb \xmm,\xmm
#else
punpcklbw \xmm,\xmm
punpcklwd \xmm,\xmm
pshufd $0,\xmm,\xmm
#endif
.endm
/ Sets all words in XMM register to first word, e.g.
/
/ mov $0x1234,%eax
/ movd %eax,%xmm0
/ pbroadcastw %xmm0
/
/ 12340000000000000000000000000000
/ 12341234123412341234123412341234
/
/ @param xmm can be %xmm0,%xmm1,etc.
.macro pbroadcastw xmm:req
#if X86_NEED(AVX2)
vpbroadcastw \xmm,\xmm
#else
punpcklwd \xmm,\xmm
pshufd $0,\xmm,\xmm
#endif
.endm