Mercurial > lcfOS
diff python/target.py @ 203:ca1ea402f6a1
Added some arm instructions
author | Windel Bouwman |
---|---|
date | Sat, 15 Jun 2013 19:13:05 +0200 |
parents | f22b431f4113 |
children | d77cb5962cc5 |
line wrap: on
line diff
--- a/python/target.py Sat Jun 15 10:02:50 2013 +0200 +++ b/python/target.py Sat Jun 15 19:13:05 2013 +0200 @@ -1,4 +1,4 @@ -from asmnodes import ASymbol, AInstruction +from asmnodes import ASymbol, AInstruction, ALabel from ppci import CompilerError """ @@ -45,16 +45,20 @@ raise CompilerError('Cannot map {0}'.format(operand)) def mapInstruction(self, vi): + assert type(vi) is AInstruction """ Map ast tree to real instruction for this target """ # map to real operands: - rops = tuple(map(self.mapOperand, vi.operands)) - optypes = tuple(map(type, rops)) # look for a suitable instruction for ic in self.instructions: - if ic.mnemonic == vi.opcode and ic.operands == optypes: - ri = ic(*rops) - return ri + if ic.mnemonic == vi.mnemonic and len(ic.operands) == len(vi.operands): + # Try to map operands to the correct operand types: + rops = [roptype.Create(vop) for roptype, vop in zip(ic.operands, vi.operands)] + + # Check if we succeeded: + optypes = tuple(map(type, rops)) + if ic.operands == optypes: + return ic(*rops) raise CompilerError('No suitable instruction found for "{0}"'.format(vi))