From 5082b2a5d71832284679a91607b53309d5e17642 Mon Sep 17 00:00:00 2001 From: David Given Date: Mon, 20 May 2013 19:56:33 +0100 Subject: [PATCH] Add lea instruction. Fix dependency issues. --HG-- branch : dtrg-videocore --- mach/proto/as/build.mk | 2 ++ mach/vc4/as/mach1.c | 2 ++ mach/vc4/as/mach2.c | 1 + mach/vc4/as/mach3.c | 1 + mach/vc4/as/mach4.c | 3 +++ mach/vc4/as/mach5.c | 23 +++++++++++++++++++++++ 6 files changed, 32 insertions(+) diff --git a/mach/proto/as/build.mk b/mach/proto/as/build.mk index 64eaab1e9..791611f3d 100644 --- a/mach/proto/as/build.mk +++ b/mach/proto/as/build.mk @@ -26,7 +26,9 @@ define build-as-impl $(eval CLEANABLES += $(OBJDIR)/$D/preprocessed-comm2.y) $(OBJDIR)/$D/preprocessed-comm2.y: mach/proto/as/comm2.y $(CPPANSI) \ + mach/$(ARCH)/as/mach1.c \ mach/$(ARCH)/as/mach2.c \ + mach/$(ARCH)/as/mach3.c \ mach/$(ARCH)/as/mach4.c @echo PREPROCESS $$@ @mkdir -p $$(dir $$@) diff --git a/mach/vc4/as/mach1.c b/mach/vc4/as/mach1.c index 440d7de97..de164610e 100644 --- a/mach/vc4/as/mach1.c +++ b/mach/vc4/as/mach1.c @@ -23,3 +23,5 @@ extern void branch_addcmp_reg_reg_instr(int cc, int rd, int ra, int rs, struct e extern void branch_addcmp_lit_reg_instr(int cc, int rd, long va, int rs, struct expr_t* expr); extern void branch_addcmp_reg_lit_instr(int cc, int rd, int ra, long vs, struct expr_t* expr); extern void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t* expr); +extern void lea_stack_instr(int rd, long va, int rs); +extern void lea_address_instr(int rd, struct expr_t* expr); \ No newline at end of file diff --git a/mach/vc4/as/mach2.c b/mach/vc4/as/mach2.c index 8143d080b..4c02efb39 100644 --- a/mach/vc4/as/mach2.c +++ b/mach/vc4/as/mach2.c @@ -18,5 +18,6 @@ %token OP_MISC %token OP_MISCL %token OP_STACK +%token OP_LEA diff --git a/mach/vc4/as/mach3.c b/mach/vc4/as/mach3.c index f47c024dd..72c0c2a88 100644 --- a/mach/vc4/as/mach3.c +++ b/mach/vc4/as/mach3.c @@ -145,3 +145,4 @@ 0, OP_MEM, B8(00000110), "ldhs", 0, OP_MEM, B8(00000111), "sths", +0, OP_LEA, 0, "lea", \ No newline at end of file diff --git a/mach/vc4/as/mach4.c b/mach/vc4/as/mach4.c index e9593e761..73cbea8e4 100644 --- a/mach/vc4/as/mach4.c +++ b/mach/vc4/as/mach4.c @@ -71,5 +71,8 @@ operation | OP_MEM CC GPR ',' '(' GPR ')' '+' '+' { mem_postincr_instr($1, $2, $3, $6); } | OP_MEM GPR ',' expr { mem_address_instr($1, $2, &$4); } + + | OP_LEA GPR ',' absexp '(' GPR ')' { lea_stack_instr($2, $4, $6); } + | OP_LEA GPR ',' expr { lea_address_instr($2, &$4); } ; diff --git a/mach/vc4/as/mach5.c b/mach/vc4/as/mach5.c index 6314ed1f3..d6f71e7fb 100644 --- a/mach/vc4/as/mach5.c +++ b/mach/vc4/as/mach5.c @@ -475,3 +475,26 @@ void branch_addcmp_lit_lit_instr(int cc, int rd, long va, long vs, struct expr_t branch_addcmp_common(B16(11000000,00000000) | (vs<<8), 8, expr); } +/* lea, where the source is relative to the stack. */ + +void lea_stack_instr(int rd, long va, int rs) +{ + if (rs != 25) + serror("source register must be sp"); + + if (!fitx(va, 6)) + serror("offset too big to encode in instruction"); + va = maskx(va, 6); + + emit2(B16(00010000,00000000) | (rd<<0) | (va<<5)); +} + +/* lea, where the source is an address. */ + +void lea_address_instr(int rd, struct expr_t* expr) +{ + newrelo(expr->typ, RELOVC4); + emit2(B16(11100101,00000000) | (rd<<0)); + emit4(expr->val); +} + -- 2.34.1