Bug 15144 – Bad operand size in asm { movdqa ... } produces bogus ubyte16 initializer error elsewhere.
Status
RESOLVED
Resolution
FIXED
Severity
minor
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
All
Creation time
2015-10-03T16:34:00Z
Last change time
2016-10-01T11:46:14Z
Keywords
diagnostic, iasm, SIMD
Assigned to
nobody
Creator
Marco.Leise
Comments
Comment #0 by Marco.Leise — 2015-10-03T16:34:41Z
--- CODE ---
void foo()
{
version (D_InlineAsm_X86_64)
{
alias csXMM = SSEFromString!`abc`;
asm @nogc nothrow
{
movdqa XMM0, [csXMM];
}
}
else static assert(0, "Not implemented");
}
template SSEFromString(string str)
{
import core.simd, std.algorithm, std.range;
enum ubyte16 SSEFromString = chain(str, '\0'.repeat(ubyte16.sizeof - str.length)).array;
}
--- ---- ---
Prints:
Error: integer constant expression expected instead of cast(__vector(ubyte[16]))[cast(ubyte)97u, cast(ubyte)98u, cast(ubyte)99u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u, cast(ubyte)0u]
Error: bad type/size of operands 'movdqa'
The nature of the message (hinting at incorrect initializer syntax) makes you think only integer constants are allowed in DMD as SIMD initializers, while in fact, fixing the asm-block will make the primary error go away and the code compile.
(Does this message still make any sense at all with SIMD? DMD accepts other things than integer constants for a while now.)
Comment #1 by Marco.Leise — 2015-10-03T20:38:33Z
Ok, using `movdqa XMM0, csXMM;` it works when the `SSEFromString` is changed to declare the vector as __gshared instead of immutable. So DMD has trouble sorting things out when they are read-only data.
void foo()
{
version (D_InlineAsm_X86_64)
{
alias csXMM = SSEFromString!`abc`;
asm @nogc nothrow
{
movdqa XMM0, csXMM;
}
}
else static assert(0, "Not implemented");
}
template SSEFromString(string str)
{
import std.algorithm, std.range;
version (DigitalMars)
__gshared ubyte16 SIMDFromString = chain(str, '\0'.repeat(ubyte16.sizeof - str.length)).array;
else
immutable ubyte16 SIMDFromString = chain(str, '\0'.repeat(ubyte16.sizeof - str.length)).array;
}