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
267 func_export : 1,267 func_export : 1,
268 func_import : 1,268 func_import : 1,
269 func_args : 5,269 func_args : 5,
270 fill : 16;270 mode : 4,
271 fill : 12;
271 struct Section *section;272 struct Section *section;
272} AttributeDef;273} AttributeDef;
273 274
@@ -278,6 +279,7 @@ typedef struct AttributeDef { · 4 unmodified lines
278#define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)279#define FUNC_ARGS(r) (((AttributeDef*)&(r))->func_args)
279#define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)280#define FUNC_ALIGN(r) (((AttributeDef*)&(r))->aligned)
280#define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)281#define FUNC_PACKED(r) (((AttributeDef*)&(r))->packed)
282#define ATTR_MODE(r) (((AttributeDef*)&(r))->mode)
281#define INT_ATTR(ad) (*(int*)(ad))283#define INT_ATTR(ad) (*(int*)(ad))
282 284
283/* -------------------------------------------------- */285/* -------------------------------------------------- */
tccgen.c+23−0
@@ -2501,6 +2501,25 @@ static void parse_attribute(AttributeDef *ad) · 2500 unmodified lines
2501 ad->func_call = FUNC_FASTCALLW;2501 ad->func_call = FUNC_FASTCALLW;
2502 break; 2502 break;
2503#endif2503#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;
2504 case TOK_DLLEXPORT:2523 case TOK_DLLEXPORT:
2505 ad->func_export = 1;2524 ad->func_export = 1;
2506 break;2525 break;
@@ -2874,6 +2893,10 @@ static int parse_btype(CType *type, AttributeDef *ad) · 367 unmodified lines
2874 case TOK_ATTRIBUTE1:2893 case TOK_ATTRIBUTE1:
2875 case TOK_ATTRIBUTE2:2894 case TOK_ATTRIBUTE2:
2876 parse_attribute(ad);2895 parse_attribute(ad);
2896 if (ATTR_MODE(ad)) {
2897 u = ATTR_MODE(ad) -1;
2898 t = (t & ~VT_BTYPE) | u;
2899 }
2877 break;2900 break;
2878 /* GNUC typeof */2901 /* GNUC typeof */
2879 case TOK_TYPEOF1:2902 case TOK_TYPEOF1:
tcctok.h+4−0
@@ -104,6 +104,10 @@ · 103 unmodified lines
104 DEF(TOK_FASTCALL1, "fastcall")104 DEF(TOK_FASTCALL1, "fastcall")
105 DEF(TOK_FASTCALL2, "__fastcall")105 DEF(TOK_FASTCALL2, "__fastcall")
106 DEF(TOK_FASTCALL3, "__fastcall__")106 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__")
107 DEF(TOK_DLLEXPORT, "dllexport")111 DEF(TOK_DLLEXPORT, "dllexport")
108 DEF(TOK_DLLIMPORT, "dllimport")112 DEF(TOK_DLLIMPORT, "dllimport")
109 DEF(TOK_NORETURN1, "noreturn")113 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