History

arm64: Implement __clear_cache.

__clear_cache is defined in lib-arm64.c with a single call to __arm64_clear_cache, which is the real built-in function and is turned into inline assembler by gen_clear_cache in arm64-gen.c

Edmund Grimley Evans committed 11 years ago

Commit d73b4881 parent 03303625 files · +63 −1Browse files

Unified · Split

5 files
  1. arm64-gen.c +48 −0
  2. lib/lib-arm64.c +1 −1
  3. tcc.h +1 −0
  4. tccgen.c +12 −0
  5. tcctok.h +1 −0
arm64-gen.c+48−0
@@ -1771,6 +1771,54 @@ ST_FUNC void ggoto(void) · 1770 unmodified lines
1771 --vtop;1771 --vtop;
1772}1772}
1773 1773
1774ST_FUNC void gen_clear_cache(void)
1775{
1776 uint32_t beg, end, dsz, isz, p, lab1, b1;
1777 gv2(RC_INT, RC_INT);
1778 vpushi(0);
1779 vtop->r = get_reg(RC_INT);
1780 vpushi(0);
1781 vtop->r = get_reg(RC_INT);
1782 vpushi(0);
1783 vtop->r = get_reg(RC_INT);
1784 beg = intr(vtop[-4].r); // x0
1785 end = intr(vtop[-3].r); // x1
1786 dsz = intr(vtop[-2].r); // x2
1787 isz = intr(vtop[-1].r); // x3
1788 p = intr(vtop[0].r); // x4
1789 vtop -= 5;
1790
1791 o(0xd53b0020 | isz); // mrs x(isz),ctr_el0
1792 o(0x52800080 | p); // mov w(p),#4
1793 o(0x53104c00 | dsz | isz << 5); // ubfx w(dsz),w(isz),#16,#4
1794 o(0x1ac02000 | dsz | p << 5 | dsz << 16); // lsl w(dsz),w(p),w(dsz)
1795 o(0x12000c00 | isz | isz << 5); // and w(isz),w(isz),#15
1796 o(0x1ac02000 | isz | p << 5 | isz << 16); // lsl w(isz),w(p),w(isz)
1797 o(0x51000400 | p | dsz << 5); // sub w(p),w(dsz),#1
1798 o(0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p)
1799 b1 = ind; o(0x14000000); // b
1800 lab1 = ind;
1801 o(0xd50b7b20 | p); // dc cvau,x(p)
1802 o(0x8b000000 | p | p << 5 | dsz << 16); // add x(p),x(p),x(dsz)
1803 *(uint32_t *)(cur_text_section->data + b1) =
1804 (0x14000000 | (ind - b1) >> 2);
1805 o(0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end)
1806 o(0x54ffffa3 | ((lab1 - ind) << 3 & 0xffffe0)); // b.cc lab1
1807 o(0xd5033b9f); // dsb ish
1808 o(0x51000400 | p | isz << 5); // sub w(p),w(isz),#1
1809 o(0x8a240004 | p | beg << 5 | p << 16); // bic x(p),x(beg),x(p)
1810 b1 = ind; o(0x14000000); // b
1811 lab1 = ind;
1812 o(0xd50b7520 | p); // ic ivau,x(p)
1813 o(0x8b000000 | p | p << 5 | isz << 16); // add x(p),x(p),x(isz)
1814 *(uint32_t *)(cur_text_section->data + b1) =
1815 (0x14000000 | (ind - b1) >> 2);
1816 o(0xeb00001f | p << 5 | end << 16); // cmp x(p),x(end)
1817 o(0x54ffffa3 | ((lab1 - ind) << 3 & 0xffffe0)); // b.cc lab1
1818 o(0xd5033b9f); // dsb ish
1819 o(0xd5033fdf); // isb
1820}
1821
1774ST_FUNC void gen_vla_sp_save(int addr) {1822ST_FUNC void gen_vla_sp_save(int addr) {
1775 tcc_error("variable length arrays unsupported for this target");1823 tcc_error("variable length arrays unsupported for this target");
1776}1824}
lib/lib-arm64.c+1−1
@@ -14,7 +14,7 @@ · 13 unmodified lines
14 14
15void __clear_cache(char *beg, char *end)15void __clear_cache(char *beg, char *end)
16{16{
17#warning __clear_cache not yet implemented17 __arm64_clear_cache(beg, end);
18}18}
19 19
20typedef struct {20typedef struct {
tcc.h+1−0
@@ -1387,6 +1387,7 @@ ST_FUNC void gen_opl(int op); · 1386 unmodified lines
1387ST_FUNC void greturn(void);1387ST_FUNC void greturn(void);
1388ST_FUNC void gen_va_start(void);1388ST_FUNC void gen_va_start(void);
1389ST_FUNC void gen_va_arg(CType *t);1389ST_FUNC void gen_va_arg(CType *t);
1390ST_FUNC void gen_clear_cache(void);
1390#endif1391#endif
1391 1392
1392/* ------------ c67-gen.c ------------ */1393/* ------------ c67-gen.c ------------ */
tccgen.c+12−0
@@ -3979,6 +3979,18 @@ ST_FUNC void unary(void) · 3978 unmodified lines
3979 vtop->type = type;3979 vtop->type = type;
3980 break;3980 break;
3981 }3981 }
3982 case TOK___arm64_clear_cache: {
3983 next();
3984 skip('(');
3985 expr_eq();
3986 skip(',');
3987 expr_eq();
3988 skip(')');
3989 gen_clear_cache();
3990 vpushi(0);
3991 vtop->type.t = VT_VOID;
3992 break;
3993 }
3982#endif3994#endif
3983 3995
3984 case TOK_INC:3996 case TOK_INC:
tcctok.h+1−0
@@ -244,6 +244,7 @@ · 243 unmodified lines
244 DEF(TOK___chkstk, "__chkstk")244 DEF(TOK___chkstk, "__chkstk")
245#endif245#endif
246#ifdef TCC_TARGET_ARM64246#ifdef TCC_TARGET_ARM64
247 DEF(TOK___arm64_clear_cache, "__arm64_clear_cache")
247 DEF(TOK___addtf3, "__addtf3")248 DEF(TOK___addtf3, "__addtf3")
248 DEF(TOK___subtf3, "__subtf3")249 DEF(TOK___subtf3, "__subtf3")
249 DEF(TOK___multf3, "__multf3")250 DEF(TOK___multf3, "__multf3")

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t