-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
backend: (riscv) Add StaticInsnsRepresentation and implement it for d…
…ma ops
- Loading branch information
1 parent
eb1b107
commit 7f28655
Showing
2 changed files
with
38 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,21 @@ | ||
from xdsl.ir import Operation | ||
from xdsl.traits import HasInsnsRepresentation | ||
|
||
|
||
class StaticInsnsRepresentation(HasInsnsRepresentation): | ||
""" | ||
Returns the first parameter as an insn template string. | ||
See https://sourceware.org/binutils/docs/as/RISC_002dV_002dDirectives.html for more information | ||
""" | ||
|
||
def get_insn(self, op: Operation) -> str: | ||
""" | ||
Return the insns representation of the operation for printing. | ||
""" | ||
insn_str = self.parameters | ||
if not isinstance(insn_str, str): | ||
raise ValueError( | ||
"Paramter of StaticInsnsRepresentation must be the insn string" | ||
) | ||
return insn_str |
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