bytecode_to_cfg.py 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. """Converts bytecode IR to CFG IR."""
  2. import modelverse_jit.bytecode_ir as bytecode_ir
  3. import modelverse_jit.cfg_ir as cfg_ir
  4. class AnalysisState(object):
  5. """State that is common to the bytecode->CFG transformation of a function."""
  6. def __init__(self):
  7. pass
  8. def analyze_if(self, instruction):
  9. raise NotImplementedError()
  10. def analyze_while(self, instruction):
  11. raise NotImplementedError()
  12. def analyze_return(self, instruction):
  13. raise NotImplementedError()
  14. def analyze_constant(self, instruction):
  15. raise NotImplementedError()
  16. def analyze_resolve(self, instruction):
  17. raise NotImplementedError()
  18. def analyze_declare(self, instruction):
  19. raise NotImplementedError()
  20. def analyze_global(self, instruction):
  21. raise NotImplementedError()
  22. def analyze_assign(self, instruction):
  23. raise NotImplementedError()
  24. def analyze_access(self, instruction):
  25. raise NotImplementedError()
  26. def analyze_output(self, instruction):
  27. raise NotImplementedError()
  28. def analyze_input(self, instruction):
  29. raise NotImplementedError()
  30. def analyze_call(self, instruction):
  31. raise NotImplementedError()
  32. def analyze_break(self, instruction):
  33. raise NotImplementedError()
  34. def analyze_continue(self, instruction):
  35. raise NotImplementedError()
  36. instruction_analyzers = {
  37. bytecode_ir.SelectInstruction : analyze_if,
  38. bytecode_ir.WhileInstruction : analyze_while,
  39. bytecode_ir.ReturnInstruction : analyze_return,
  40. bytecode_ir.ConstantInstruction : analyze_constant,
  41. bytecode_ir.ResolveInstruction : analyze_resolve,
  42. bytecode_ir.DeclareInstruction : analyze_declare,
  43. bytecode_ir.GlobalInstruction : analyze_global,
  44. bytecode_ir.AssignInstruction : analyze_assign,
  45. bytecode_ir.AccessInstruction : analyze_access,
  46. bytecode_ir.OutputInstruction : analyze_output,
  47. bytecode_ir.InputInstruction : analyze_input,
  48. bytecode_ir.CallInstruction : analyze_call,
  49. bytecode_ir.BreakInstruction : analyze_break,
  50. bytecode_ir.ContinueInstruction : analyze_continue
  51. }