-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a mov op that moves data from source to destination --------- Co-authored-by: emmau678 <eu233@Emma-laptop> Co-authored-by: Sasha Lopoukhine <[email protected]>
- Loading branch information
1 parent
f66c9b2
commit 91d3100
Showing
5 changed files
with
154 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,14 @@ | ||
// RUN: XDSL_ROUNDTRIP | ||
// RUN: XDSL_GENERIC_ROUNDTRIP | ||
// RUN: xdsl-opt -t arm-asm %s | filecheck %s --check-prefix=CHECK-ASM | ||
|
||
|
||
// CHECK: %x1 = arm.get_register : !arm.reg<x1> | ||
%x1 = arm.get_register : !arm.reg<x1> | ||
|
||
// CHECK: %ds_mov = arm.ds.mov %x1 {"comment" = "move contents of s to d"} : (!arm.reg<x1>) -> !arm.reg<x2> | ||
// CHECK-ASM: mov x2, x1 # move contents of s to d | ||
%ds_mov = arm.ds.mov %x1 {"comment" = "move contents of s to d"} : (!arm.reg<x1>) -> !arm.reg<x2> | ||
|
||
// CHECK-GENERIC: %x1 = "arm.get_register"() : () -> !arm.reg<x1> | ||
// CHECK-GENERIC: %ds_mov = "arm.ds.mov"(%x1) {"comment" = "move contents of s to d"} : (!arm.reg<x1>) -> !arm.reg<x2> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import TypeAlias | ||
|
||
from xdsl.dialects.arm.register import ARMRegisterType | ||
from xdsl.dialects.builtin import StringAttr | ||
from xdsl.ir import SSAValue | ||
|
||
AssemblyInstructionArg: TypeAlias = SSAValue | ||
|
||
|
||
def append_comment(line: str, comment: StringAttr | None) -> str: | ||
if comment is None: | ||
return line | ||
|
||
padding = " " * max(0, 48 - len(line)) | ||
|
||
return f"{line}{padding} # {comment.data}" | ||
|
||
|
||
def assembly_arg_str(arg: AssemblyInstructionArg) -> str: | ||
if isinstance(arg.type, ARMRegisterType): | ||
reg = arg.type.register_name | ||
return reg | ||
else: | ||
raise ValueError(f"Unexpected register type {arg.type}") | ||
|
||
|
||
def assembly_line( | ||
name: str, | ||
arg_str: str, | ||
comment: StringAttr | None = None, | ||
is_indented: bool = True, | ||
) -> str: | ||
code = " " if is_indented else "" | ||
code += name | ||
if arg_str: | ||
code += f" {arg_str}" | ||
code = append_comment(code, comment) | ||
return code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters