Bug 1231 – GDC std.intrinsic: inline asm for x86 & x86_64

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
All
Creation time
2007-05-14T13:30:00Z
Last change time
2015-06-09T05:15:10Z
Keywords
patch
Assigned to
ibuclaw
Creator
fvbommel

Attachments

IDFilenameSummaryContent-TypeSize
147intrinsic.diffthe patch for x86 & x86_64text/plain6104

Comments

Comment #0 by fvbommel — 2007-05-14T13:30:12Z
In the current version of std.intrinsic distributed with GDC the functions don't take advantage of the assembly instructions after which they're named. While reimplementation in D is more portable, it rather detracts from its value on platforms where such instructions are available. Additionally, the inp* and outp* functions simply don't do anything as implemented (except return 0 or the value passed in, respectively). I'm attaching a patch that fixes this for x86 and x86_64 by supplying simple assembler functions (using extended assembler syntax for optimizability). The functions for bs* and bt* are generated by mixins since these are "families" of similar instructions. The template for bt* can also generate locked versions but is not instantiated that way since std.intrinsic doesn't currently provide locked versions, and I just wanted to fix the functions already present. I also changed the port parameter of inp* and outp* from uint to ushort, since port numbers are 16 bits on x86 variants (for which these functions were designed). If this is undesirable, this can easily be undone by s/ushort p/uint p/ and s/[port] "Nd" p/[port] "Nd" cast(ushort)p/.
Comment #1 by fvbommel — 2007-05-14T13:31:10Z
Created attachment 147 the patch for x86 & x86_64
Comment #2 by ibuclaw — 2011-03-21T13:05:46Z
The asm implementations you gave were put into gcc.bitmanip for D2 as a temporary stopgap (thanks!), but all functions in std.intrinsic are now compiler-generated. So no use keeping this bug report around now. Regards