diff options
| author | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-09 20:41:43 +0300 |
|---|---|---|
| committer | Kimplul <kimi.h.kuparinen@gmail.com> | 2024-04-09 20:41:43 +0300 |
| commit | 52d8eda04d1e2e33bf4c09713d83360453cec435 (patch) | |
| tree | 9f1822814233ab604204ee6d482be6d5a4798ddc | |
| parent | 9295e8f445dae6431f8e7c543eb8c374742b136d (diff) | |
| download | qbt-52d8eda04d1e2e33bf4c09713d83360453cec435.tar.gz qbt-52d8eda04d1e2e33bf4c09713d83360453cec435.zip | |
add blit to instructions
| -rw-r--r-- | include/qbt/nodes.h | 2 | ||||
| -rw-r--r-- | src/lexer.l | 2 | ||||
| -rw-r--r-- | src/parser.y | 9 | ||||
| -rw-r--r-- | tests/blit.qbt | 9 |
4 files changed, 21 insertions, 1 deletions
diff --git a/include/qbt/nodes.h b/include/qbt/nodes.h index b8c601b..98d36c6 100644 --- a/include/qbt/nodes.h +++ b/include/qbt/nodes.h @@ -19,6 +19,7 @@ enum insn_type { ALLOC, COPY, MOVE, + BLIT, EQ, NE, LE, @@ -68,6 +69,7 @@ enum insn_flags { M(ALLOC) \ M(COPY) \ M(MOVE) \ + M(BLIT) \ M(EQ) \ M(NE) \ M(LE) \ diff --git a/src/lexer.l b/src/lexer.l index 75e2b09..35fc5a7 100644 --- a/src/lexer.l +++ b/src/lexer.l @@ -124,6 +124,8 @@ STRING \"(\\.|[^"\\])*\" "->" {return LEXTHINARROW;} ">>" {return LEXTO;} "<<" {return LEXFROM;} +"<<*" {return LEXBLIT;} +"^" {return LEXALLOC;} "i9" {return LEXI9;} "i27" {return LEXI27;} diff --git a/src/parser.y b/src/parser.y index c0653bd..24a2ebe 100644 --- a/src/parser.y +++ b/src/parser.y @@ -59,7 +59,9 @@ %token LEXTHINARROW "->" %token LEXTO ">>" %token LEXFROM "<<" +%token LEXBLIT "<<*" %token LEXSEMI ";" +%token LEXALLOC "^" %token LEXI9 "i9" %token LEXI27 "i27" @@ -370,9 +372,14 @@ mem /* really not a huge fan or 'reusing' the output slot... */ INSADD(STORE, $[type], noclass(), b, t, $[mem_off]); } + | id "<<*" int id { + struct val t = IDTOVAL($1); + struct val f = IDTOVAL($4); + INSADD(BLIT, NOTYPE, noclass(), t, f, $[int]); + } stack - : type id "=" "alloc" int { + : type id "=" "^" int { struct val t = IDALLOC($[id]); INSADD(ALLOC, $[type], t, noclass(), noclass(), $[int]); } diff --git a/tests/blit.qbt b/tests/blit.qbt new file mode 100644 index 0000000..b8fa0d3 --- /dev/null +++ b/tests/blit.qbt @@ -0,0 +1,9 @@ +main() +{ + /* alloc */ + i27 a = ^ 16; + i27 b = ^ 16; + /* blit */ + b <<* 16 a; + => (); +} |
