blob: 2b288f8640dd475964f37af7da8ffec86d91ca6e (
plain) (
tree)
|
|
class Op(object):
__slots__ = ["name"]
def __init__(self, name):
self.name = name
def __str__(self):
return self.name
def __repr__(self):
return "<Tag: %s>" % self
Op.ADD = Op("ADD") # x = y + z -> y z x
Op.SUB = Op("SUB") # x = y - z -> y z x
Op.MUL = Op("MUL") # x = y * z -> y z x
Op.DIV = Op("DIV") # x = y / z -> y z x
Op.MOD = Op("MOD") # x = y % z -> y z x
Op.AND = Op("AND") # x = y AND z -> y z x
Op.OR = Op("OR") # x = y OR z -> y z x
Op.NOT = Op("NOT") # x = !y -> y None x
Op.MINUS = Op("MINUS") # x = - y -> y None x
Op.ASSIGN = Op("ASSIGN") # x = y -> y None x
Op.JMP = Op("JMP") # "goto" x -> x
Op.BEQ = Op("BEQ") # "if y == z" goto x -> y z x
Op.BNE = Op("BNE") # "if y != z" goto x -> y z x
Op.BLE = Op("BLE") # ...
Op.BGE = Op("BGE")
Op.BLT = Op("BLT")
Op.BGT = Op("BGT")
Op.PARAM = Op("PARAM") # param x -> x
Op.CALL = Op("CALL") # fun y (z-args..) -> y z
Op.RETURN = Op("RETURN") # return x -> x
Op.ARRAYGET = Op("ARRAYGET") # x = y[i] -> y i x
Op.ARRAYSET = Op("ARRAYSET") # x[i] = y -> y i x
class ThreeAddressCode:
def __init__(self,op,arg1=None,arg2=None,result=None):
self.op = op
self.arg1 = arg1
self.arg2 = arg2
self.result = result
|