History

tcc/lib: reduce number of files

271 insertions(+), 292 deletions(-), -21 lines, -5 files Also: - tccdefs.h: WIN32: less (no) __builtins - libtcc.c: simply ignore -arch

grischka committed 5 years ago

Commit 675046b1 parent e53816016 files · +271 −292Browse files

Showing the changes to lib (11 of 16 files). Show all

Unified · Split

11 files
  1. lib/Makefile +5 −5
  2. lib/alloca-arm.S +0 −10
  3. lib/alloca-bt.S +46 −1
  4. lib/alloca.S +85 −0
  5. lib/alloca86-bt.S +0 −52
  6. lib/alloca86.S +0 −36
  7. lib/alloca86_64.S +0 −38
  8. lib/fetch_and_add.S +67 −0
  9. lib/fetch_and_add_arm.S +0 −15
  10. lib/fetch_and_add_arm64.S +0 −22
  11. lib/fetch_and_add_riscv64.S +0 −16
lib/Makefile+5−5
@@ -42,11 +42,11 @@ $(X)BT_O += tcov.o · 41 unmodified lines
4242
4343 DSO_O = dsohandle.o
4444
45−I386_O = libtcc1.o alloca86.o alloca86-bt.o $(BT_O) stdatomic.o
46−X86_64_O = libtcc1.o alloca86_64.o alloca86_64-bt.o $(BT_O) stdatomic.o
47−ARM_O = libtcc1.o armeabi.o alloca-arm.o armflush.o fetch_and_add_arm.o $(BT_O)
48−ARM64_O = lib-arm64.o fetch_and_add_arm64.o $(BT_O)
49−RISCV64_O = lib-arm64.o fetch_and_add_riscv64.o $(BT_O)
45+I386_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
46+X86_64_O = libtcc1.o alloca.o alloca-bt.o $(BT_O) stdatomic.o
47+ARM_O = libtcc1.o armeabi.o alloca.o armflush.o fetch_and_add.o $(BT_O)
48+ARM64_O = lib-arm64.o fetch_and_add.o $(BT_O)
49+RISCV64_O = lib-arm64.o fetch_and_add.o $(BT_O)
5050 WIN_O = crt1.o crt1w.o wincrt1.o wincrt1w.o dllcrt1.o dllmain.o
5151
5252 OBJ-i386 = $(I386_O) $(BCHECK_O) $(DSO_O)
lib/alloca-arm.S+0−10
@@ -1,10 +0,0 @@
1− .text
2− .align 2
3− .global alloca
4− .type alloca, %function
5−alloca:
6− rsb sp, r0, sp
7− bic sp, sp, #7
8− mov r0, sp
9− mov pc, lr
10− .size alloca, .-alloca
lib/alloca-bt.Srenamed from lib/alloca86_64-bt.S+46−1
@@ -1,5 +1,5 @@
11 /* ---------------------------------------------- */
2−/* alloca86_64.S */
2+/* alloca-bt.S */
33
44 #ifdef __leading_underscore
55 # define _(s) _##s
@@ -7,6 +7,50 @@ · 1 unmodified line
77 # define _(s) s
88 #endif
99
10+/* ---------------------------------------------- */
11+#if defined __i386__
12+
13+.globl _(__bound_alloca)
14+_(__bound_alloca):
15+ pop %edx
16+ pop %eax
17+ mov %eax, %ecx
18+ add $3+1,%eax
19+ and $-4,%eax
20+ jz p6
21+
22+#ifdef _WIN32
23+p4:
24+ cmp $4096,%eax
25+ jbe p5
26+ test %eax,-4096(%esp)
27+ sub $4096,%esp
28+ sub $4096,%eax
29+ jmp p4
30+
31+p5:
32+#endif
33+
34+ sub %eax,%esp
35+ mov %esp,%eax
36+
37+ push %edx
38+ push %eax
39+ push %ecx
40+ push %eax
41+ call _(__bound_new_region)
42+ add $8, %esp
43+ pop %eax
44+ pop %edx
45+
46+p6:
47+ push %edx
48+ push %edx
49+ ret
50+
51+/* ---------------------------------------------- */
52+#elif defined __x86_64__
53+
1054 .globl _(__bound_alloca)
1155 _(__bound_alloca):
1256 #ifdef _WIN32
@@ -49,3 +93,4 @@ p3: · 36 unmodified lines
4993 #endif
5094
5195 /* ---------------------------------------------- */
96+#endif
lib/alloca.S+85−0
@@ -0,0 +1,85 @@
1+/* ---------------------------------------------- */
2+/* alloca.S */
3+
4+#ifdef __leading_underscore
5+# define _(s) _##s
6+#else
7+# define _(s) s
8+#endif
9+
10+/* ---------------------------------------------- */
11+#if defined __i386__
12+
13+.globl _(alloca), _(__alloca)
14+_(alloca):
15+_(__alloca):
16+ push %ebp
17+ mov %esp,%ebp
18+ mov 8(%ebp),%eax
19+ add $3,%eax
20+ and $-4,%eax
21+#ifdef _WIN32
22+ jmp .+16 #p2
23+p1:
24+ sub $4096,%esp
25+ sub $4096,%eax
26+ test %eax,(%esp)
27+p2:
28+ cmp $4096,%eax
29+ jae p1
30+#endif
31+ sub %eax,%esp
32+ mov 4(%ebp),%eax
33+ mov 0(%ebp),%ebp
34+ add $8,%esp
35+ push %eax
36+ lea 8(%esp),%eax
37+ ret
38+
39+/* ---------------------------------------------- */
40+#elif defined __x86_64__
41+
42+.globl _(alloca)
43+_(alloca):
44+ pop %rdx
45+#ifdef _WIN32
46+ mov %rcx,%rax
47+#else
48+ mov %rdi,%rax
49+#endif
50+ add $15,%rax
51+ and $-16,%rax
52+ jz p3
53+
54+#ifdef _WIN32
55+p1:
56+ cmp $4096,%rax
57+ jbe p2
58+ test %rax,-4096(%rsp)
59+ sub $4096,%rsp
60+ sub $4096,%rax
61+ jmp p1
62+p2:
63+#endif
64+ sub %rax,%rsp
65+ mov %rsp,%rax
66+p3:
67+ push %rdx
68+ ret
69+
70+/* ---------------------------------------------- */
71+#elif defined __arm__
72+
73+ .text
74+ .align 2
75+ .global alloca
76+ .type alloca, %function
77+alloca:
78+ rsb sp, r0, sp
79+ bic sp, sp, #7
80+ mov r0, sp
81+ mov pc, lr
82+ .size alloca, .-alloca
83+
84+/* ---------------------------------------------- */
85+#endif
lib/alloca86-bt.S+0−52
@@ -1,52 +0,0 @@
1−/* ---------------------------------------------- */
2−/* alloca86-bt.S */
3−
4−#ifdef __leading_underscore
5−# define _(s) _##s
6−#else
7−# define _(s) s
8−#endif
9−
10−.globl _(__bound_alloca)
11−_(__bound_alloca):
12− pop %edx
13− pop %eax
14− mov %eax, %ecx
15− add $3+1,%eax
16− and $-4,%eax
17− jz p6
18−
19−#ifdef _WIN32
20−p4:
21− cmp $4096,%eax
22− jbe p5
23− test %eax,-4096(%esp)
24− sub $4096,%esp
25− sub $4096,%eax
26− jmp p4
27−
28−p5:
29−#endif
30−
31− sub %eax,%esp
32− mov %esp,%eax
33−
34− push %edx
35− push %eax
36− push %ecx
37− push %eax
38− call _(__bound_new_region)
39− add $8, %esp
40− pop %eax
41− pop %edx
42−
43−p6:
44− push %edx
45− push %edx
46− ret
47−
48−/* mark stack as nonexecutable */
49−#if defined __ELF__ && defined __linux__
50− .section .note.GNU-stack,"",@progbits
51−#endif
52−/* ---------------------------------------------- */
lib/alloca86.S+0−36
@@ -1,36 +0,0 @@
1−/* ---------------------------------------------- */
2−/* alloca86.S */
3−
4−#ifdef __leading_underscore
5−# define _(s) _##s
6−#else
7−# define _(s) s
8−#endif
9−
10−.globl _(alloca), _(__alloca)
11−_(alloca):
12−_(__alloca):
13− push %ebp
14− mov %esp,%ebp
15− mov 8(%ebp),%eax
16− add $3,%eax
17− and $-4,%eax
18−#ifdef _WIN32
19− jmp .+16 #p2
20−p1:
21− sub $4096,%esp
22− sub $4096,%eax
23− test %eax,(%esp)
24−p2:
25− cmp $4096,%eax
26− jae p1
27−#endif
28− sub %eax,%esp
29− mov 4(%ebp),%eax
30− mov 0(%ebp),%ebp
31− add $8,%esp
32− push %eax
33− lea 8(%esp),%eax
34− ret
35−
36−/* ---------------------------------------------- */
lib/alloca86_64.S+0−38
@@ -1,38 +0,0 @@
1−/* ---------------------------------------------- */
2−/* alloca86_64.S */
3−
4−#ifdef __leading_underscore
5−# define _(s) _##s
6−#else
7−# define _(s) s
8−#endif
9−
10−.globl _(alloca)
11−_(alloca):
12− pop %rdx
13−#ifdef _WIN32
14− mov %rcx,%rax
15−#else
16− mov %rdi,%rax
17−#endif
18− add $15,%rax
19− and $-16,%rax
20− jz p3
21−
22−#ifdef _WIN32
23−p1:
24− cmp $4096,%rax
25− jbe p2
26− test %rax,-4096(%rsp)
27− sub $4096,%rsp
28− sub $4096,%rax
29− jmp p1
30−p2:
31−#endif
32− sub %rax,%rsp
33− mov %rsp,%rax
34−p3:
35− push %rdx
36− ret
37−
38−/* ---------------------------------------------- */
lib/fetch_and_add.S+67−0
@@ -0,0 +1,67 @@
1+/* ---------------------------------------------- */
2+#if defined __arm__
3+
4+ .text
5+ .align 2
6+ .global fetch_and_add_arm
7+ .type fetch_and_add_arm, %function
8+fetch_and_add_arm:
9+ mcr p15, #0, r0, c7, c10, #5
10+.L0:
11+ ldrex r3, [r0]
12+ add r3, r3, r1
13+ strex r2, r3, [r0]
14+ cmp r2, #0
15+ bne .L0
16+ mcr p15, #0, r0, c7, c10, #5
17+ bx lr
18+ .size fetch_and_add_arm, .-fetch_and_add_arm
19+
20+/* ---------------------------------------------- */
21+#elif defined __aarch64__
22+
23+ .text
24+ .align 2
25+ .global fetch_and_add_arm64
26+ .type fetch_and_add_arm64, %function
27+fetch_and_add_arm64:
28+#ifdef __TINYC__
29+ .int 0x885f7c02
30+ .int 0x0b010042
31+ .int 0x8803fc02
32+ .int 0x35ffffa3
33+ .int 0xd5033bbf
34+ .int 0xd65f03c0
35+#else
36+ ldxr w2, [x0]
37+ add w2, w2, w1
38+ stlxr w3, w2, [x0]
39+ cbnz w3, fetch_and_add_arm64
40+ dmb ish
41+ ret
42+#endif
43+
44+ .size fetch_and_add_arm64, .-fetch_and_add_arm64
45+
46+/* ---------------------------------------------- */
47+#elif defined __riscv
48+
49+ .text
50+ .align 2
51+ .global fetch_and_add_riscv64
52+ .type fetch_and_add_riscv64, %function
53+fetch_and_add_riscv64:
54+#ifdef __TINYC__
55+ .int 0x0f50000f
56+ .int 0x004b5202f
57+ .short 0x8082
58+#else
59+ fence iorw,ow
60+ amoadd.w.aq zero,a1,0(a0)
61+ ret
62+#endif
63+
64+ .size fetch_and_add_riscv64, .-fetch_and_add_riscv64
65+
66+/* ---------------------------------------------- */
67+#endif
lib/fetch_and_add_arm.S+0−15
@@ -1,15 +0,0 @@
1− .text
2− .align 2
3− .global fetch_and_add_arm
4− .type fetch_and_add_arm, %function
5−fetch_and_add_arm:
6− mcr p15, #0, r0, c7, c10, #5
7−.L0:
8− ldrex r3, [r0]
9− add r3, r3, r1
10− strex r2, r3, [r0]
11− cmp r2, #0
12− bne .L0
13− mcr p15, #0, r0, c7, c10, #5
14− bx lr
15− .size fetch_and_add_arm, .-fetch_and_add_arm
lib/fetch_and_add_arm64.S+0−22
@@ -1,22 +0,0 @@
1− .text
2− .align 2
3− .global fetch_and_add_arm64
4− .type fetch_and_add_arm64, %function
5−fetch_and_add_arm64:
6−#ifdef __TINYC__
7− .int 0x885f7c02
8− .int 0x0b010042
9− .int 0x8803fc02
10− .int 0x35ffffa3
11− .int 0xd5033bbf
12− .int 0xd65f03c0
13−#else
14− ldxr w2, [x0]
15− add w2, w2, w1
16− stlxr w3, w2, [x0]
17− cbnz w3, fetch_and_add_arm64
18− dmb ish
19− ret
20−#endif
21−
22− .size fetch_and_add_arm64, .-fetch_and_add_arm64
lib/fetch_and_add_riscv64.S+0−16
@@ -1,16 +0,0 @@
1− .text
2− .align 2
3− .global fetch_and_add_riscv64
4− .type fetch_and_add_riscv64, %function
5−fetch_and_add_riscv64:
6−#ifdef __TINYC__
7− .int 0x0f50000f
8− .int 0x004b5202f
9− .short 0x8082
10−#else
11− fence iorw,ow
12− amoadd.w.aq zero,a1,0(a0)
13− ret
14−#endif
15−
16− .size fetch_and_add_riscv64, .-fetch_and_add_riscv64

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