public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug d/105413] New: gdc extended assembler cannot constraints r8 - r15
@ 2022-04-27 23:13 witold.baryluk+gcc at gmail dot com
2022-06-24 18:55 ` [Bug d/105413] " cvs-commit at gcc dot gnu.org
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2022-04-27 23:13 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105413
Bug ID: 105413
Summary: gdc extended assembler cannot constraints r8 - r15
Product: gcc
Version: 12.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: d
Assignee: ibuclaw at gdcproject dot org
Reporter: witold.baryluk+gcc at gmail dot com
Target Milestone: ---
gcc in C does not support directly register constraints for x86_64 registers r8
- r15.
In C this can be done however using local register variables and asm
attributes.
https://gcc.gnu.org/onlinedocs/gcc/Local-Register-Variables.html
There is no way to use this in GDC extended assembler.
version (linux) {
version (GNU) {
enum SYSCALL {
OPENAT = 56,
}
@nogc:
nothrow:
size_t syscall(SYSCALL ident)(size_t arg1, size_t arg2, size_t arg3, size_t
arg4) {
version (X86_64) {
asm @nogc nothrow {
"syscall"
// output:
: "=a" (arg1)
// inputs:
: "a" (ident), // rax - syscall number
"D" (arg1), // rdi - arg1
"S" (arg2), // rsi - arg2
"d" (arg3), // rdx - arg3
"r10" (arg4), // r10 - arg4
"m"( *cast(ubyte*)arg1) // "dummy" input instead of full memory
clobber
// clobers
: "c", "r11"; // Clobers rax, and rcx and r11.
}
return arg1;
} else {
static assert(false, "This platform/architecture is not supported when
using GDC compiler");
}
}
}
private int openatdummy() @nogc nothrow {
return cast(int)syscall!(SYSCALL.OPENAT)(0, 0, 0, 0);
}
}
myio.d: In function ‘syscall’:
myio.d:232:10: error: matching constraint references invalid operand number
232 | ;
https://godbolt.org/z/xGzxa6orc
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/105413] gdc extended assembler cannot constraints r8 - r15
2022-04-27 23:13 [Bug d/105413] New: gdc extended assembler cannot constraints r8 - r15 witold.baryluk+gcc at gmail dot com
@ 2022-06-24 18:55 ` cvs-commit at gcc dot gnu.org
2022-06-24 19:19 ` ibuclaw at gdcproject dot org
2022-10-08 20:08 ` witold.baryluk+gcc at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2022-06-24 18:55 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105413
--- Comment #1 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Iain Buclaw <ibuclaw@gcc.gnu.org>:
https://gcc.gnu.org/g:91418c42089cd1cbe71edcd6b2f5b26559819372
commit r13-1255-g91418c42089cd1cbe71edcd6b2f5b26559819372
Author: Iain Buclaw <ibuclaw@gdcproject.org>
Date: Thu Jun 23 18:24:07 2022 +0200
d: Add `@register' attribute to compiler and library.
The `@register` attribute specifies that a local or `__gshared` variable
is to be given a register storage-class in the C sense of the term, and
will be placed into a register named `registerName`.
The variable needs to boiled down to a data type that fits the target
register. It also cannot have either thread-local or `extern` storage.
It is an error to take the address of a register variable.
PR d/105413
gcc/d/ChangeLog:
* d-attribs.cc (d_handle_register_attribute): New function.
(d_langhook_attribute_table): Add register attribute.
* d-codegen.cc (d_mark_addressable): Error if taken address of
register variable.
(build_frame_type): Error if register variable has non-local
references.
* d-tree.h (d_mark_addressable): Add complain parameter.
* decl.cc (get_symbol_decl): Mark register varibles DECL_REGISTER.
Error when register variable declared thread-local or extern.
* expr.cc (ExprVisitor::visit (IndexExp *)): Don't complain about
marking register vectors as addressable in an ARRAY_REF.
libphobos/ChangeLog:
* libdruntime/gcc/attributes.d (register): Define.
gcc/testsuite/ChangeLog:
* gdc.dg/attr_register1.d: New test.
* gdc.dg/attr_register2.d: New test.
* gdc.dg/attr_register3.d: New test.
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/105413] gdc extended assembler cannot constraints r8 - r15
2022-04-27 23:13 [Bug d/105413] New: gdc extended assembler cannot constraints r8 - r15 witold.baryluk+gcc at gmail dot com
2022-06-24 18:55 ` [Bug d/105413] " cvs-commit at gcc dot gnu.org
@ 2022-06-24 19:19 ` ibuclaw at gdcproject dot org
2022-10-08 20:08 ` witold.baryluk+gcc at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: ibuclaw at gdcproject dot org @ 2022-06-24 19:19 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105413
Iain Buclaw <ibuclaw at gdcproject dot org> changed:
What |Removed |Added
----------------------------------------------------------------------------
Resolution|--- |FIXED
Status|UNCONFIRMED |RESOLVED
--- Comment #2 from Iain Buclaw <ibuclaw at gdcproject dot org> ---
@register attribute has been added, meaning that you can now have the following
as an alternative to your example.
---
import gcc.attributes : register;
@register("rax") SYSCALL rax = ident; // rax - syscall number
@register("rdi") size_t rdi = arg1; // rdi - arg1
@register("rsi") size_t rsi = arg2; // rsi - arg2
@register("rdx") size_t rdx = arg3; // rdx - arg3
@register("r10") size_t r10 = arg4; // r10 - arg4
asm @nogc nothrow {
"syscall"
: "=r" (rax)
// inputs:
: "r" (rax),
"r" (rdi),
"r" (rsi),
"r" (rdx),
"r" (r10),
"m"( *cast(ubyte*)arg1) // "dummy" input instead of full memory clobber
// clobers
: "rcx", "r11"; // Clobers rax, and rcx and r11.
}
return rax;
---
https://godbolt.org/z/PvnTsea9T
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug d/105413] gdc extended assembler cannot constraints r8 - r15
2022-04-27 23:13 [Bug d/105413] New: gdc extended assembler cannot constraints r8 - r15 witold.baryluk+gcc at gmail dot com
2022-06-24 18:55 ` [Bug d/105413] " cvs-commit at gcc dot gnu.org
2022-06-24 19:19 ` ibuclaw at gdcproject dot org
@ 2022-10-08 20:08 ` witold.baryluk+gcc at gmail dot com
2 siblings, 0 replies; 4+ messages in thread
From: witold.baryluk+gcc at gmail dot com @ 2022-10-08 20:08 UTC (permalink / raw)
To: gcc-bugs
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105413
--- Comment #3 from Witold Baryluk <witold.baryluk+gcc at gmail dot com> ---
It works. Thank you.
Any chance this will be in gcc 12.x? I work a lot on Debian Linux, and I doubt
I will have gcc trunk or gcc 13 available any time soon.
Also weirdly gcc does not inline this function, unless I add
@attribute("always_inline") on syscall, or @attribute("flatten") on
openatdummy.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-10-08 20:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-27 23:13 [Bug d/105413] New: gdc extended assembler cannot constraints r8 - r15 witold.baryluk+gcc at gmail dot com
2022-06-24 18:55 ` [Bug d/105413] " cvs-commit at gcc dot gnu.org
2022-06-24 19:19 ` ibuclaw at gdcproject dot org
2022-10-08 20:08 ` witold.baryluk+gcc at gmail dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).