From 7bb14210a7d79dbb9b371c35f8fc18e4720dc9d8 Mon Sep 17 00:00:00 2001 From: Antoine Viallon Date: Tue, 23 May 2023 00:37:36 +0200 Subject: [PATCH] ir: add IRNop and IRVoid action and value (resp.) --- compiler/ir.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/compiler/ir.py b/compiler/ir.py index beafd7c..0ea1569 100644 --- a/compiler/ir.py +++ b/compiler/ir.py @@ -31,6 +31,17 @@ class IRAction(IRItem, abc.ABC): pass +class IRNop(IRAction): + def __init__(self, location: SourceLocation): + super().__init__(location) + + def codegen(self) -> str: + return "NOP" + + def destination(self) -> IRValue: + return IRVoid(self.location) + + class IRValue(IRItem, abc.ABC): def destination(self) -> IRValue: return self @@ -61,6 +72,15 @@ class IRImmediate(IRValue): return f"{self.value}" +class IRVoid(IRValue): + @typecheck + def __init__(self, location: SourceLocation): + super().__init__(location) + + def codegen(self) -> str: + return "" + + class IRAssignable(IRValue, metaclass=abc.ABCMeta): pass