Browse Source

Improve error message

master
Forest Belton 3 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: case LocType.REGISTER:
if (isA(ssa.dest) && typeof ssa.source !== 'number' && ssa.source.type === LocType.VARIABLE) { if (isA(ssa.dest) && typeof ssa.source !== 'number' && ssa.source.type === LocType.VARIABLE) {
output.push(`LD A, (${ssa.source.name})`) 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) { } else if (source !== ssa.dest.name) {
output.push(`LD ${ssa.dest.name}, ${source}`) output.push(`LD ${ssa.dest.name}, ${source}`)
} }
@ -57,8 +56,7 @@ export const generateSSA_Copy = (alloc: RegAlloc, ssa: AbsInsnCopy): Array
case LocType.VARIABLE: case LocType.VARIABLE:
if (source !== R8.A) { 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`) output.push(`LD (${ssa.dest.name}), A`)
break break

Loading…
Cancel
Save