History

Move asm label functions from tccasm.c to tccgen.c

* Move functions parse_asm_str and asm_label_instr from tccasm.c to tccgen.c * Remove CONFIG_TCC_ASM_LABEL macro as asm label are available on all archs. See: http://lists.nongnu.org/archive/html/tinycc-devel/2010-09/msg00026.html for the rationale.

Thomas Preud'homme committed 16 years ago

Commit b8adf001 parent 25962734 files · +29 −44Browse files

Unified · Split

4 files
  1. libtcc.c +0 −6
  2. tcc.h +1 −2
  3. tccasm.c +0 −35
  4. tccgen.c +28 −1
libtcc.c+0−6
@@ -72,12 +72,6 @@ ST_DATA void *rt_prog_main; · 71 unmodified lines
72#endif /* ALL_IN_ONE */72#endif /* ALL_IN_ONE */
73 73
74/********************************************************/74/********************************************************/
75#ifndef CONFIG_TCC_ASM_LABEL
76ST_FUNC void asm_label_instr(CString *)
77{
78 error("inline asm() not supported");
79}
80#endif
81#ifndef CONFIG_TCC_ASM75#ifndef CONFIG_TCC_ASM
82ST_FUNC void asm_instr(void)76ST_FUNC void asm_instr(void)
83{77{
tcc.h+1−2
@@ -122,7 +122,6 @@ · 121 unmodified lines
122#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)122#if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
123#define CONFIG_TCC_ASM123#define CONFIG_TCC_ASM
124#endif124#endif
125#define CONFIG_TCC_ASM_LABEL
126 125
127/* object format selection */126/* object format selection */
128#if defined(TCC_TARGET_C67)127#if defined(TCC_TARGET_C67)
@@ -1073,6 +1072,7 @@ ST_FUNC int type_size(CType *type, int *a); · 944 unmodified lines
1073ST_FUNC void mk_pointer(CType *type);1072ST_FUNC void mk_pointer(CType *type);
1074ST_FUNC void vstore(void);1073ST_FUNC void vstore(void);
1075ST_FUNC void inc(int post, int c);1074ST_FUNC void inc(int post, int c);
1075ST_FUNC void parse_asm_str(CString *astr);
1076ST_FUNC int lvalue_type(int t);1076ST_FUNC int lvalue_type(int t);
1077ST_FUNC void indir(void);1077ST_FUNC void indir(void);
1078ST_FUNC void unary(void);1078ST_FUNC void unary(void);
@@ -1196,7 +1196,6 @@ ST_FUNC int tcc_load_coff(TCCState * s1, int fd); · 117 unmodified lines
1196 1196
1197/* ------------ tccasm.c ------------ */1197/* ------------ tccasm.c ------------ */
1198ST_FUNC void asm_instr(void);1198ST_FUNC void asm_instr(void);
1199ST_FUNC void asm_label_instr(CString *);
1200ST_FUNC void asm_global_instr(void);1199ST_FUNC void asm_global_instr(void);
1201 1200
1202#ifdef CONFIG_TCC_ASM1201#ifdef CONFIG_TCC_ASM
tccasm.c+0−35
@@ -18,8 +18,6 @@ · 17 unmodified lines
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 */19 */
20 20
21#ifdef CONFIG_TCC_ASM
22
23#include "tcc.h"21#include "tcc.h"
24 22
25ST_FUNC int asm_get_local_label_name(TCCState *s1, unsigned int n)23ST_FUNC int asm_get_local_label_name(TCCState *s1, unsigned int n)
@@ -993,37 +991,6 @@ static void parse_asm_operands(ASMOperand *operands, int *nb_operands_ptr, · 967 unmodified lines
993 }991 }
994}992}
995 993
996#endif
997
998static void parse_asm_str(CString *astr)
999{
1000 skip('(');
1001 /* read the string */
1002 if (tok != TOK_STR)
1003 expect("string constant");
1004 cstr_new(astr);
1005 while (tok == TOK_STR) {
1006 /* XXX: add \0 handling too ? */
1007 cstr_cat(astr, tokc.cstr->data);
1008 next();
1009 }
1010 cstr_ccat(astr, '\0');
1011}
1012
1013/* Parse an asm label and return the label
1014 * Don't forget to free the CString in the caller! */
1015static void asm_label_instr(CString *astr)
1016{
1017 next();
1018 parse_asm_str(astr);
1019 skip(')');
1020#ifdef ASM_DEBUG
1021 printf("asm_alias: \"%s\"\n", (char *)astr->data);
1022#endif
1023}
1024
1025#ifdef CONFIG_TCC_ASM
1026
1027/* parse the GCC asm() instruction */994/* parse the GCC asm() instruction */
1028ST_FUNC void asm_instr(void)995ST_FUNC void asm_instr(void)
1029{996{
@@ -1154,5 +1121,3 @@ ST_FUNC void asm_global_instr(void) · 124 unmodified lines
1154 1121
1155 cstr_free(&astr);1122 cstr_free(&astr);
1156}1123}
1157
1158#endif
tccgen.c+28−1
@@ -2991,6 +2991,33 @@ static inline void convert_parameter_type(CType *pt) · 2990 unmodified lines
2991 }2991 }
2992}2992}
2993 2993
2994ST_FUNC void parse_asm_str(CString *astr)
2995{
2996 skip('(');
2997 /* read the string */
2998 if (tok != TOK_STR)
2999 expect("string constant");
3000 cstr_new(astr);
3001 while (tok == TOK_STR) {
3002 /* XXX: add \0 handling too ? */
3003 cstr_cat(astr, tokc.cstr->data);
3004 next();
3005 }
3006 cstr_ccat(astr, '\0');
3007}
3008
3009/* Parse an asm label and return the label
3010 * Don't forget to free the CString in the caller! */
3011static void asm_label_instr(CString *astr)
3012{
3013 next();
3014 parse_asm_str(astr);
3015 skip(')');
3016#ifdef ASM_DEBUG
3017 printf("asm_alias: \"%s\"\n", (char *)astr->data);
3018#endif
3019}
3020
2994static void post_type(CType *type, AttributeDef *ad)3021static void post_type(CType *type, AttributeDef *ad)
2995{3022{
2996 int n, l, t1, arg_size, align;3023 int n, l, t1, arg_size, align;
@@ -5325,7 +5352,7 @@ ST_FUNC void decl(int l) · 2328 unmodified lines
5325 Sym *sym;5352 Sym *sym;
5326 AttributeDef ad;5353 AttributeDef ad;
5327 5354
5328 /* 5355 /*
5329 * type.ref must be either a valid reference or NULL for external_sym to5356 * type.ref must be either a valid reference or NULL for external_sym to
5330 * work. As type = btype is executed before external_sym is call, setting5357 * work. As type = btype is executed before external_sym is call, setting
5331 * btype.ref to 0 is enough.5358 * btype.ref to 0 is enough.

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