Browse Source

Improve error message

master
Forest Belton 2 years ago
parent
commit
121337160f
1 changed files with 2 additions and 4 deletions
  1. +2
    -4
      lib/sm83/codegen.ts

+ 2
- 4
lib/sm83/codegen.ts View File

@ -48,8 +48,7 @@ export const generateSSA_Copy = (alloc: RegAlloc, ssa: AbsInsnCopy): Array
case LocType.REGISTER:
if (isA(ssa.dest) && typeof ssa.source !== 'number' && ssa.source.type === LocType.VARIABLE) {
output.push(`LD A, (${ssa.source.name})`)
// TODO: Remove check with peephole optimizer
// TODO: Remove check later with peephole optimizer
} else if (source !== ssa.dest.name) {
output.push(`LD ${ssa.dest.name}, ${source}`)
}
@ -57,8 +56,7 @@ export const generateSSA_Copy = (alloc: RegAlloc, ssa: AbsInsnCopy): Array
case LocType.VARIABLE:
if (source !== R8.A) {
console.log(source, ssa)
throw new Error("unsupported")
throw new Error(`can only deref address into A (had ${source})`)
}
output.push(`LD (${ssa.dest.name}), A`)
break

Loading…
Cancel
Save