bit-manipulation - How to access the new x86 bit-manipulation instructions from Common Lisp?
问题描述
I want to use the new bit manipulation instructions available in the latest Intel and AMD chips, in particular the "Parallel Bits Extract" PEXT
instruction (see here and here). How can I access these instructions from within Common Lisp? (specifically SBCL).
Ideally, I would like to access these instructions through a library that detects whether the CPU provides them and, if it doesn't, it emulates them in software. Compilers for other languages provide such functions (e.g., GCC provides the function _pext_u32
; see here).
解决方案
我认为要真正添加对它的支持,您需要修改编译器本身。这可能涉及添加一个新的 VOP(参见 sbcl 源代码中的 vop.lisp)定义一个编译到它的新函数(可能在 sb-ext 包中)并将其连接起来。我实际上无法告诉您如何做到这一点,我对此的理解只是肤浅的。
另一种可能更可移植的方法是创建一个 C 库,其中包含在汇编中使用新原语的函数,然后将其包装在 CFFI 绑定中。
推荐阅读
- java - 将浮点数表示为十六进制
- javascript - 在发布请求 Angular 9 后显示引导警报成功
- spring-security - 集成 Swagger 和以前工作的代码中断:无法从 Object 值反序列化(没有基于委托或属性的 Creator
- chronicle-map - ChronicleMap Recovery with multi process application
- java - Get specific value from JSON array using java
- javascript - Export button in datatable does not take filters into consideration
- c - C中如何根据hwnd获取进程名
- java - How to find usages of an Inteface used by Class.this in Intellij
- r - Computing histogram of particular column variable in R
- python - ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output.- when trying to install pyjnius