Mercurial > lcfOS
diff python/target/arminstructionselector.py @ 322:44f336460c2a
Half of use of burg spec for arm
author | Windel Bouwman |
---|---|
date | Mon, 27 Jan 2014 19:58:07 +0100 |
parents | e84047f29c78 |
children | e9fe6988497c |
line wrap: on
line diff
--- a/python/target/arminstructionselector.py Sun Jan 19 18:48:45 2014 +0100 +++ b/python/target/arminstructionselector.py Mon Jan 27 19:58:07 2014 +0100 @@ -1,5 +1,8 @@ +import os from ppci import ir from ppci.irmach import AbstractInstruction as makeIns +from ppci.ir2tree import makeTree +import pyburg from .basetarget import Label, Comment, Alignment, LabelRef, DebugInfo, Nop from .instructionselector import InstructionSelector from .arminstructions import Orr, Lsl, Str2, Ldr2, Ldr3 @@ -8,10 +11,33 @@ from .arminstructions import Add, Sub, Cmp, Sub2, Add2, Mul from .basetarget import Imm8, Imm7, Imm3 +# Import BURG spec for arm: +spec_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'arm.brg') +arm_matcher = pyburg.load_as_module(spec_file) + +class ArmMatcher(arm_matcher.Matcher): + def __init__(self): + super().__init__() + + def newTmp(self): + pass + + def emit(self, *args, **kwargs): + pass + class ArmInstructionSelector(InstructionSelector): """ Instruction selector for the arm architecture """ + def __init__(self): + super().__init__() + self.matcher = ArmMatcher() + def munchExpr(self, e): + #t = makeTree(e) + #print(t) + #return self.matcher.gen(t) + + # TODO: below is obsolete: if isinstance(e, ir.Binop) and e.operation == '+' and \ isinstance(e.b, ir.Const) and e.b.value < 8: a = self.munchExpr(e.a)