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
7272 #endif /* ALL_IN_ONE */
7373
7474 /********************************************************/
75−#ifndef CONFIG_TCC_ASM_LABEL
76−ST_FUNC void asm_label_instr(CString *)
77−{
78− error("inline asm() not supported");
79−}
80−#endif
8175 #ifndef CONFIG_TCC_ASM
8276 ST_FUNC void asm_instr(void)
8377 {
tcc.h+1−2
@@ -122,7 +122,6 @@ · 121 unmodified lines
122122 #if !defined(TCC_TARGET_ARM) && !defined(TCC_TARGET_C67)
123123 #define CONFIG_TCC_ASM
124124 #endif
125−#define CONFIG_TCC_ASM_LABEL
126125
127126 /* object format selection */
128127 #if defined(TCC_TARGET_C67)
@@ -1073,6 +1072,7 @@ ST_FUNC int type_size(CType *type, int *a); · 944 unmodified lines
10731072 ST_FUNC void mk_pointer(CType *type);
10741073 ST_FUNC void vstore(void);
10751074 ST_FUNC void inc(int post, int c);
1075+ST_FUNC void parse_asm_str(CString *astr);
10761076 ST_FUNC int lvalue_type(int t);
10771077 ST_FUNC void indir(void);
10781078 ST_FUNC void unary(void);
@@ -1196,7 +1196,6 @@ ST_FUNC int tcc_load_coff(TCCState * s1, int fd); · 117 unmodified lines
11961196
11971197 /* ------------ tccasm.c ------------ */
11981198 ST_FUNC void asm_instr(void);
1199−ST_FUNC void asm_label_instr(CString *);
12001199 ST_FUNC void asm_global_instr(void);
12011200
12021201 #ifdef CONFIG_TCC_ASM
tccasm.c+0−35
@@ -18,8 +18,6 @@ · 17 unmodified lines
1818 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
1919 */
2020
21−#ifdef CONFIG_TCC_ASM
22−
2321 #include "tcc.h"
2422
2523 ST_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
993991 }
994992 }
995993
996−#endif
997−
998−static 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! */
1015−static 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−
1027994 /* parse the GCC asm() instruction */
1028995 ST_FUNC void asm_instr(void)
1029996 {
@@ -1154,5 +1121,3 @@ ST_FUNC void asm_global_instr(void) · 124 unmodified lines
11541121
11551122 cstr_free(&astr);
11561123 }
1157−
1158−#endif
tccgen.c+28−1
@@ -2991,6 +2991,33 @@ static inline void convert_parameter_type(CType *pt) · 2990 unmodified lines
29912991 }
29922992 }
29932993
2994+ST_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! */
3011+static 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+
29943021 static void post_type(CType *type, AttributeDef *ad)
29953022 {
29963023 int n, l, t1, arg_size, align;
@@ -5325,7 +5352,7 @@ ST_FUNC void decl(int l) · 2328 unmodified lines
53255352 Sym *sym;
53265353 AttributeDef ad;
53275354
5328− /*
5355+ /*
53295356 * type.ref must be either a valid reference or NULL for external_sym to
53305357 * work. As type = btype is executed before external_sym is call, setting
53315358 * 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