A "high-level" language for the Gameboy
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
825 B

  1. import type { BinaryOp, UnaryOp } from "../ast"
  2. import type { Loc } from "./loc"
  3. export type Operand = Loc | number
  4. export type AbsInsnCopy = {
  5. type: "copy",
  6. dest: Loc,
  7. source: Operand,
  8. }
  9. export type AbsInsn2Unary = {
  10. type: "unary",
  11. dest: Loc,
  12. // NOTE: We convert binary -> unary when going SSA3 -> SSA2
  13. op: UnaryOp | BinaryOp,
  14. source: Operand,
  15. }
  16. // Abstract instruction in two-address form
  17. export type AbsInsn2 = AbsInsnCopy | AbsInsn2Unary
  18. export type AbsInsn3Unary = {
  19. type: "unary",
  20. dest: Loc,
  21. op: UnaryOp,
  22. source: Operand,
  23. }
  24. export type AbsInsnBinary = {
  25. type: "binary",
  26. dest: Loc,
  27. source: Operand,
  28. op: BinaryOp,
  29. source1: Operand
  30. }
  31. // Abstract instruction in three-address form
  32. export type AbsInsn3 = AbsInsnCopy | AbsInsn3Unary | AbsInsnBinary