forked from crtc-demos/gcc-ia16
-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
IA-16: add
__attribute__ ((cdecl))',
__attribute__ ((stdcall))'
As requested (#13) by Bart Oldeman. I also added a few test cases --- gcc.traget/ia16/rtd-{2, 3, 4, 5}.c --- to test that these attributes work properly.
- Loading branch information
Showing
8 changed files
with
206 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/* { dg-do run } */ | ||
/* { dg-options "-Os --save-temps" } */ | ||
|
||
/* Test whether `__attribute__ ((stdcall))' works correctly, and still gets | ||
the program linked with the correct (non-stdcall) libgcc multilib. */ | ||
|
||
extern void abort (void); | ||
|
||
volatile unsigned long long quotient = 0x55bde67343803983ull, | ||
divisor = 0x1670107447a23170ull; | ||
|
||
__attribute__ ((stdcall)) unsigned | ||
inc (unsigned x) | ||
{ | ||
return x + 1; | ||
} | ||
|
||
int | ||
main (int argc, char **argv) | ||
{ | ||
unsigned i; | ||
|
||
/* If this code is linked against the wrong libgcc, this loop will | ||
eventually cause a stack overflow and corrupt the data area. */ | ||
for (i = 0; i < 10000; ++i) | ||
{ | ||
unsigned long long mod = quotient % divisor; | ||
if (mod != 0x126db5166c99a533ull) | ||
abort (); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/* inc (.) should pop one shortword: */ | ||
/* { dg-final { scan-assembler "ret\[ \\t\]\\\$2" } } */ | ||
|
||
/* main (...) should _not_ pop two shortwords: */ | ||
/* { dg-final { scan-assembler-not "ret\[ \\t\]\\\$4" } } */ | ||
|
||
/* main (...) should adjust the stack after calling __umoddi3: */ | ||
/* { dg-final { scan-assembler "addw\[ \\t\]\\$.*,\[ \\t\]%sp" } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* { dg-do run } */ | ||
/* { dg-options "-mrtd -Os --save-temps" } */ | ||
|
||
/* Test whether the `-mrtd' switch in conjunction with __attribute__ | ||
((cdecl)) works correctly and links with the correct libgcc multilib. */ | ||
|
||
extern void abort (void); | ||
|
||
volatile unsigned long long quotient = 0x55bde67343803983ull, | ||
divisor = 0x1670107447a23170ull; | ||
|
||
unsigned | ||
inc (unsigned x) | ||
{ | ||
return x + 1; | ||
} | ||
|
||
__attribute__ ((cdecl)) int | ||
main (int argc, char **argv) | ||
{ | ||
unsigned i; | ||
|
||
for (i = 0; i < 10000; ++i) | ||
{ | ||
unsigned long long mod = quotient % divisor; | ||
if (mod != 0x126db5166c99a533ull) | ||
abort (); | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
/* inc (.) should pop one shortword: */ | ||
/* { dg-final { scan-assembler "ret\[ \\t\]\\\$2" } } */ | ||
|
||
/* main (...) should _not_ pop two shortwords: */ | ||
/* { dg-final { scan-assembler-not "ret\[ \\t\]\\\$4" } } */ | ||
|
||
/* main (...) should not adjust the stack after calling __umoddi3: */ | ||
/* { dg-final { scan-assembler-not "addw\[ \\t\]\\$.*,\[ \\t\]%sp" } } */ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* { dg-do assemble } */ | ||
/* { dg-xfail-if "" *-*-* } */ | ||
/* { dg-options "-mrtd -Os --save-temps" } */ | ||
|
||
/* XFAIL: the `cdecl' and `stdcall' attributes do not mix. */ | ||
|
||
__attribute__ ((cdecl, stdcall)) unsigned | ||
inc (unsigned x) | ||
{ | ||
return x + 1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/* { dg-do assemble } */ | ||
/* { dg-xfail-if "" *-*-* } */ | ||
/* { dg-options "-mrtd -Os --save-temps" } */ | ||
|
||
/* XFAIL: the `cdecl' and `stdcall' attributes do not mix. */ | ||
|
||
__attribute__ ((stdcall, cdecl)) unsigned | ||
inc (unsigned x) | ||
{ | ||
return x + 1; | ||
} |
e6295a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what about Pascal call?
e6295a6
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello @roytam1 ,
Currently most other calling conventions --- including
pascal
,thiscall
,watcall
, etc. --- are unimplemented. But for now, if you need to, you can emulate the Borland Pascal calling convention by declaring astdcall
function with its arguments in reverse order.Thank you!