History

Add support for the __mode__ attribute

-- By by ... Detlef

Detlef Riekenberg committed 16 years ago

Commit a9750081 parent 26505843 files · +30 −1Browse files

Unified · Split

3 files
  1. tcc.h +3 −1
  2. tccgen.c +23 −0
  3. tcctok.h +4 −0
tcc.h+3−1
@@ -267,7 +267,8 @@ typedef struct AttributeDef { · 266 unmodified lines
267267 func_export : 1,
268268 func_import : 1,
269269 func_args : 5,
270− fill : 16;
270+ mode : 4,
271+ fill : 12;
271272 struct Section *section;
272273 } AttributeDef;
273274
@@ -278,6 +279,7 @@ typedef struct AttributeDef { · 4 unmodified lines
278279 #define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)
279280 #define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)
280281 #define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)
282+#define ATTR_MODE(r) (((AttributeDef*)&(r))->mode)
281283 #define INT_ATTR(ad) (*(int*)(ad))
282284
283285 /* -------------------------------------------------- */
tccgen.c+23−0
@@ -2501,6 +2501,25 @@ static void parse_attribute(AttributeDef *ad) · 2500 unmodified lines
25012501 ad->func_call = FUNC_FASTCALLW;
25022502 break;
25032503 #endif
2504+ case TOK_MODE:
2505+ skip('(');
2506+ switch(tok) {
2507+ case TOK_MODE_DI:
2508+ ad->mode = VT_LLONG + 1;
2509+ break;
2510+ case TOK_MODE_HI:
2511+ ad->mode = VT_SHORT + 1;
2512+ break;
2513+ case TOK_MODE_SI:
2514+ ad->mode = VT_INT + 1;
2515+ break;
2516+ default:
2517+ warning("__mode__(%s) not supported\n", get_tok_str(tok, NULL));
2518+ break;
2519+ }
2520+ next();
2521+ skip(')');
2522+ break;
25042523 case TOK_DLLEXPORT:
25052524 ad->func_export = 1;
25062525 break;
@@ -2874,6 +2893,10 @@ static int parse_btype(CType *type, AttributeDef *ad) · 367 unmodified lines
28742893 case TOK_ATTRIBUTE1:
28752894 case TOK_ATTRIBUTE2:
28762895 parse_attribute(ad);
2896+ if (ATTR_MODE(ad)) {
2897+ u = ATTR_MODE(ad) -1;
2898+ t = (t & ~VT_BTYPE) | u;
2899+ }
28772900 break;
28782901 /* GNUC typeof */
28792902 case TOK_TYPEOF1:
tcctok.h+4−0
@@ -104,6 +104,10 @@ · 103 unmodified lines
104104 DEF(TOK_FASTCALL1, "fastcall")
105105 DEF(TOK_FASTCALL2, "__fastcall")
106106 DEF(TOK_FASTCALL3, "__fastcall__")
107+ DEF(TOK_MODE, "__mode__")
108+ DEF(TOK_MODE_DI, "__DI__")
109+ DEF(TOK_MODE_HI, "__HI__")
110+ DEF(TOK_MODE_SI, "__SI__")
107111 DEF(TOK_DLLEXPORT, "dllexport")
108112 DEF(TOK_DLLIMPORT, "dllimport")
109113 DEF(TOK_NORETURN1, "noreturn")

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