From 12be827731009fbe86ecc7711ff7338ee6a80432 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Wed, 5 May 2010 14:58:55 +0200 Subject: [PATCH] codea: orterme --- codea/code.bfe | 3 +++ codea/parser.y | 26 ++++++++++++++++++-------- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/codea/code.bfe b/codea/code.bfe index cd30f85..7c0c074 100644 --- a/codea/code.bfe +++ b/codea/code.bfe @@ -55,6 +55,9 @@ expr: O_ADD(imm,expr) # 2 # gen_e_imm(bnode, "addq"); expr: O_MUL(expr,exprno) # 1 # gen_e_eno(bnode, "imulq"); expr: O_MUL(expr,imm) # 2 # gen_e_imm(bnode, "imulq"); +expr: O_OR(expr,exprno) # 1 # gen_e_eno(bnode, "orq"); +expr: O_OR(expr,imm) # 2 # gen_e_imm(bnode, "orq"); + exprno: O_ID # 0 # /* brauchen wir nicht 'zwischenlagern', weil nur gelesen wird */ exprno: expr diff --git a/codea/parser.y b/codea/parser.y index 4e460e0..74fe1f4 100644 --- a/codea/parser.y +++ b/codea/parser.y @@ -43,8 +43,7 @@ @attributes { struct symbol *f; } FeldID Structdef Program @attributes { struct symbol *s; } Methoddef @attributes { struct symbol *s; int gparamges; } Statseq Exprs -@attributes { struct symbol *s; int gparamges; struct treenode *node; short imm; int exprcount; } Expr Minusterm Term Multerm -@attributes { struct symbol *s; int gparamges; struct treenode *node; int exprcount; } Orterm +@attributes { struct symbol *s; int gparamges; struct treenode *node; short imm; int exprcount; } Expr Minusterm Term Multerm Orterm @attributes { struct symbol *s; int gparamges; struct treenode *node; } Lexpr Feld @attributes { struct symbol *sin; int gparamges; struct symbol *sout; struct treenode *node; } Statement @@ -250,8 +249,16 @@ Expr: | Term Orterm @{ - @i @Expr.node@ = TREENULL; @i @Expr.exprcount@ = @Term.exprcount@ + @Orterm.exprcount@; fprintf(stderr, "(Expr)- Term Orterm\n"); + @i @Expr.node@ = new_node(O_OR, @Term.node@, @Orterm.node@, @Expr.exprcount@); + @i @Expr.imm@ = @Term.imm@ && @Orterm.imm@; + + @reg { + /* TODO */ + @Term.node@->reg = @Expr.node@->reg; + @Term.node@->skip = 0; + @Orterm.node@->reg = next_reg(@Term.node@->reg, @Expr.node@->skip, @Expr.gparamges@); + } @} | Term '<' Term @@ -313,15 +320,18 @@ Orterm: OR Term Orterm @{ @i @Orterm.0.exprcount@ = @Term.exprcount@ + @Orterm.1.exprcount@; fprintf(stderr, "(Orterm)- - Term Orterm\n"); - /* TODO */ - /* TODO: imm */ - @i @Orterm.node@ = TREENULL; + @i @Orterm.node@ = new_node(O_OR, @Orterm.1.node@, @Term.node@, @Orterm.0.exprcount@); + @i @Orterm.imm@ = @Term.imm@ && @Orterm.1.imm@; + + @reg { + @Orterm.1.node@->reg = @Orterm.node@->reg; + @Term.node@->reg = next_reg(@Orterm.1.node@->reg, @Orterm.node@->skip, @Orterm.gparamges@); + } @} | OR Term @{ @i @Orterm.exprcount@ = @Term.exprcount@; fprintf(stderr, "(Orterm)- - Term\n"); - /* TODO */ - @i @Orterm.node@ = TREENULL; + @reg @Term.node@->reg = @Orterm.node@->reg; @} ; -- 2.25.1