Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow spaces instead of commas in macro definitions and invocations #62

Merged
merged 2 commits into from
Jul 8, 2024

Conversation

mkannwischer
Copy link
Collaborator

The GNU as [1] allows macro definitons and invoation to separate arguments by spaces or commas. So far SLOTHY cannot handle spaces in both definitions and invocations.
This commit adds that functionality.

Here is some minimal examples for which SLOTHY currently fails:

.macro mx aa bb cc
    add \aa, \bb, \cc
.endm

.macro my aa, bb, cc
    add \aa, \bb, \cc
.endm

start:
mx x3, x1, x2
mx x4  x1  x2
my x5, x1, x2
my x6  x1  x2
end:

The following SLOTHY calls can be used to test:

import logging
import sys
from slothy import Slothy

import slothy.targets.aarch64.aarch64_neon as AArch64_Neon
import slothy.targets.aarch64.cortex_a55 as Target_CortexA55

logging.basicConfig(stream=sys.stdout, level=logging.INFO)

arch = AArch64_Neon
target = Target_CortexA55

slothy = Slothy(arch, target)

slothy.load_source_from_file("sample.s")
slothy.config.outputs=["x3", "x4", "x5", "x6"]

slothy.optimize(start="start", end="end")
slothy.write_source_to_file("opt.s")

[1] https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_node/as_107.html

The GNU as [1] allows macro definitons and invoation to separate
arguments by spaces or commas. So far SLOTHY cannot handle spaces in
both definitions and invocations.
This commit adds that functionality.

Here is some minimal examples for which SLOTHY currently fails:

```
.macro mx aa bb cc
    add \aa, \bb, \cc
.endm

.macro my aa, bb, cc
    add \aa, \bb, \cc
.endm

start:
mx x3, x1, x2
mx x4  x1  x2
my x5, x1, x2
my x6  x1  x2
end:
```

The following SLOTHY calls can be used to test:
```
import logging
import sys
from slothy import Slothy

import slothy.targets.aarch64.aarch64_neon as AArch64_Neon
import slothy.targets.aarch64.cortex_a55 as Target_CortexA55

logging.basicConfig(stream=sys.stdout, level=logging.INFO)

arch = AArch64_Neon
target = Target_CortexA55

slothy = Slothy(arch, target)

slothy.load_source_from_file("sample.s")
slothy.config.outputs=["x3", "x4", "x5", "x6"]

slothy.optimize(start="start", end="end")
slothy.write_source_to_file("opt.s")
```

[1] https://ftp.gnu.org/old-gnu/Manuals/gas-2.9.1/html_node/as_107.html
@mkannwischer
Copy link
Collaborator Author

mkannwischer commented Jul 8, 2024

Don't merge this yet. I'm investigating another problem that have been caused by this change.
All good.

@hanno-becker hanno-becker merged commit c6930b8 into main Jul 8, 2024
7 checks passed
@mkannwischer mkannwischer deleted the macros branch July 8, 2024 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants