view python/ir/instruction.py @ 147:4e79484a9d47

Moved core to ir folder
author Windel Bouwman
date Fri, 22 Feb 2013 10:33:48 +0100
parents python/ppci/core/instruction.py@9e552d34bd60
children b28a11c01dbe
line wrap: on
line source


from .value import Value

def Enum(**enums):
   return type('Enum', (), enums)

class Instruction(Value):
   """ Base class for all instructions. """
   pass

class CallInstruction(Instruction):
   def __init__(self, callee, arguments):
      super().__init__()
      self.callee = callee
      self.arguments = arguments

BinOps = Enum(Add=1, Sub=2, Mul=3)

class BinaryOperator(Instruction):
   def __init__(self, operation, value1, value2):
      assert value1
      assert value2
      print('operation is in binops:', operation in BinOps)
      # Check types of the two operands:
      self.value1 = value1
      self.value2 = value2
      self.operation = operation

class LoadInstruction(Instruction):
   def __init__(self, ptr, name, insertBefore):
      self.setName(name)