Skip to content

Commit a476e91

Browse files
WalterBrightthewilsonator
authored andcommitted
add stub file iasmaarch64.d for AArch64 inline assembler
1 parent f6c1b9a commit a476e91

4 files changed

Lines changed: 77 additions & 3 deletions

File tree

compiler/src/build.d

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1558,7 +1558,7 @@ auto sourceFiles()
15581558
}
15591559
DmdSources dmd = {
15601560
glue: fileArray(env["D"], "
1561-
dmsc.d e2ir.d iasmdmd.d glue.d objc_glue.d
1561+
dmsc.d e2ir.d iasmdmd.d iasmaarch64.d glue.d objc_glue.d
15621562
s2ir.d tocsym.d toctype.d tocvdebug.d todt.d toir.d toobj.d
15631563
"),
15641564
driver: fileArray(env["D"], "dinifile.d dmdparams.d gluelayer.d lib/package.d lib/elf.d lib/mach.d lib/mscoff.d

compiler/src/dmd/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,8 @@ Note that these groups have no strict meaning, the category assignments are a bi
171171
| File | Purpose |
172172
|-------------------------------------------------------------------------|-------------------------------------------|
173173
| [iasm.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasm.d) | Inline assembly depending on the compiler |
174-
| [iasmdmd.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasmdmd.d) | Inline assembly for DMD |
174+
| [iasmdmd.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasmdmd.d) | Inline assembly for DMD X86_64 |
175+
| [iasmaarch64.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasmaarch64.d) | Inline assembly for DMD AArch64 |
175176
| [iasmgcc.d](https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasmgcc.d) | Inline assembly for GDC |
176177

177178
**Other**

compiler/src/dmd/iasm.d

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import dmd.dsymbol;
2020
import dmd.expression;
2121
import dmd.func;
2222
import dmd.mtype;
23+
import dmd.target;
2324
import dmd.tokens;
2425
import dmd.statement;
2526
import dmd.statementsem;
@@ -34,6 +35,7 @@ else version (IN_GCC)
3435
else
3536
{
3637
import dmd.iasmdmd;
38+
import dmd.iasmaarch64;
3739
version = MARS;
3840
}
3941

@@ -73,7 +75,9 @@ Statement asmSemantic(AsmStatement s, Scope* sc)
7375
}
7476
auto ias = new InlineAsmStatement(s.loc, s.tokens);
7577
ias.caseSensitive = s.caseSensitive;
76-
return inlineAsmSemantic(ias, sc);
78+
return (target.isAArch64)
79+
? inlineAsmAArch64Semantic(ias, sc)
80+
: inlineAsmSemantic(ias, sc); // X86_64
7781
}
7882
else version (IN_GCC)
7983
{

compiler/src/dmd/iasmaarch64.d

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/**
2+
* Inline assembler implementation for DMD.
3+
* https://dlang.org/spec/iasm.html
4+
*
5+
* Copyright: Copyright (C) 2025 by The D Language Foundation, All Rights Reserved
6+
* Authors: Walter Bright
7+
* License: $(LINK2 https://www.boost.org/LICENSE_1_0.txt, Boost License 1.0)
8+
* Source: $(LINK2 https://github.com/dlang/dmd/blob/master/compiler/src/dmd/iasmaarch64.d, _iasmaarch64.d)
9+
* Documentation: https://dlang.org/phobos/dmd_iasmaarch64.html
10+
* Coverage: https://codecov.io/gh/dlang/dmd/src/master/compiler/src/dmd/iasmaarch64.d
11+
*/
12+
13+
module dmd.iasmaarch64;
14+
15+
import core.stdc.stdio;
16+
import core.stdc.stdarg;
17+
import core.stdc.stdlib;
18+
import core.stdc.string;
19+
20+
import dmd.astenums;
21+
import dmd.declaration;
22+
import dmd.denum;
23+
import dmd.dinterpret;
24+
import dmd.dmdparams;
25+
import dmd.dscope;
26+
import dmd.dsymbol;
27+
import dmd.errors;
28+
import dmd.expression;
29+
import dmd.expressionsem;
30+
import dmd.funcsem : checkNestedReference;
31+
import dmd.globals;
32+
import dmd.id;
33+
import dmd.identifier;
34+
import dmd.init;
35+
import dmd.location;
36+
import dmd.mtype;
37+
import dmd.optimize;
38+
import dmd.statement;
39+
import dmd.target;
40+
import dmd.tokens;
41+
import dmd.typesem : pointerTo, size;
42+
43+
import dmd.root.ctfloat;
44+
import dmd.common.outbuffer;
45+
import dmd.root.rmem;
46+
import dmd.rootobject;
47+
48+
import dmd.backend.cc;
49+
import dmd.backend.cdef;
50+
import dmd.backend.code;
51+
import dmd.backend.x86.code_x86;
52+
import dmd.backend.codebuilder : CodeBuilder;
53+
import dmd.backend.global;
54+
import dmd.backend.iasm;
55+
56+
/************************
57+
* Perform semantic analysis on InlineAsmStatement.
58+
* Params:
59+
* s = inline asm statement
60+
* sc = context
61+
* Returns:
62+
* `s` on success, ErrorStatement if errors happened
63+
*/
64+
public Statement inlineAsmAArch64Semantic(InlineAsmStatement s, Scope* sc)
65+
{
66+
//printf("InlineAsmAArch64Statement.semantic()\n");
67+
error(s.loc, "AArch64 inline assembler not implemented (yet!)");
68+
return new ErrorStatement();
69+
}

0 commit comments

Comments
 (0)