import type { BinaryOp, UnaryOp } from "../ast"
|
|
import type { Loc } from "./loc"
|
|
|
|
export type Operand = Loc | number
|
|
|
|
export type AbsInsnCopy = {
|
|
type: "copy",
|
|
dest: Loc,
|
|
source: Operand,
|
|
}
|
|
|
|
export type AbsInsn2Unary = {
|
|
type: "unary",
|
|
dest: Loc,
|
|
// NOTE: We convert binary -> unary when going SSA3 -> SSA2
|
|
op: UnaryOp | BinaryOp,
|
|
source: Operand,
|
|
}
|
|
|
|
// Abstract instruction in two-address form
|
|
export type AbsInsn2 = AbsInsnCopy | AbsInsn2Unary
|
|
|
|
export type AbsInsn3Unary = {
|
|
type: "unary",
|
|
dest: Loc,
|
|
op: UnaryOp,
|
|
source: Operand,
|
|
}
|
|
|
|
export type AbsInsnBinary = {
|
|
type: "binary",
|
|
dest: Loc,
|
|
source: Operand,
|
|
op: BinaryOp,
|
|
source1: Operand
|
|
}
|
|
|
|
// Abstract instruction in three-address form
|
|
export type AbsInsn3 = AbsInsnCopy | AbsInsn3Unary | AbsInsnBinary
|