Home My Page Projects Code Snippets Project Openings SML/NJ
Summary Activity Forums Tracker Lists Tasks Docs Surveys News SCM Files

SCM Repository

[smlnj] Diff of /MLRISC/trunk/x86/staged-allocation/test-varargs.c
ViewVC logotype

Diff of /MLRISC/trunk/x86/staged-allocation/test-varargs.c

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 3063, Thu Jun 5 00:42:15 2008 UTC revision 3064, Thu Jun 5 07:20:32 2008 UTC
# Line 4  Line 4 
4    
5  #define NEW(ty)   (ty*)malloc(sizeof(ty))  #define NEW(ty)   (ty*)malloc(sizeof(ty))
6    
 extern void varargs (void* fun, void* args, int);  
   
7  typedef struct {  typedef struct {
8    long long val;    long long val;
9    long long kind;    long long kind;
# Line 13  Line 11 
11    long long ty;    long long ty;
12  }  zipped_arg_t;  }  zipped_arg_t;
13    
14  typedef struct varargs_s {  extern void varargs (void* fun, zipped_arg_t* args, int);
   zipped_arg_t* hd;  
   int pad;  
   struct varargs_s* tl;  
 } varargs_t;  
15    
16  void Say (const char *fmt, ...)  void Say (const char *fmt, ...)
17          __attribute__ ((format(printf, 1, 2)));          __attribute__ ((format(printf, 1, 2)));
# Line 33  Line 27 
27    
28  }  }
29    
30  #define N_ARGS 1  #define N_ARGS 2
31  #define STK 2  #define STK 2
32  #define FSTK 3  #define FSTK 3
33  #define OFF(i) (i*4)  #define OFF(i) (i*4)
34    
 int alignb (int n) {  
   n += 2;  
   n *= sizeof(long long*);  
   n += 16-(n%16);  
   return n-(2*sizeof(void*));  
 }  
   
35  int main ()  int main ()
36  {  {
37    varargs_t* args[N_ARGS];    zipped_arg_t args[N_ARGS];
38    
39    for(int i = 0 ; i < N_ARGS; i++)    for(int i = 0 ; i < N_ARGS; i++)
40      args[i] = NEW(varargs_t);      args[i] = NEW(varargs_t);
# Line 56  Line 43 
43    for (int i = N_ARGS-2; i >= 0; i--)    for (int i = N_ARGS-2; i >= 0; i--)
44      args[i]->tl = args[i+1];      args[i]->tl = args[i+1];
45    
46    args[0]->hd = NEW(zipped_arg_t);    args[0].hd->val = (long long)"arg1=%d\n";
47    args[0]->hd->val = (long long)"arg1=%d\n";    args[0].hd->kind = (long long)STK;
48    args[0]->hd->kind = (long long)STK;    args[0].hd->loc = (long long)OFF(0);
49    args[0]->hd->loc = (long long)OFF(0);    args[0].hd->ty = (long long)32;
50    args[0]->hd->ty = (long long)32;  
51    /*    args[1].hd->val = (long long)69;
52    args[1]->hd = NEW(zipped_arg_t);    args[1].hd->kind = (long long)STK;
53    args[1]->hd->val = (long long)69;    args[1].hd->loc = (long long)OFF(1);
54    args[1]->hd->kind = (long long)STK;    args[1].hd->ty = (long long)32;
   args[1]->hd->loc = (long long)OFF(1);  
   args[1]->hd->ty = (long long)32;  
   */  
55    
56    varargs(Say, args[0], alignb(N_ARGS));    varargs(Say, args, N_ARGS);
57    
58    return 0;    return 0;
59  }  }

Legend:
Removed from v.3063  
changed lines
  Added in v.3064

root@smlnj-gforge.cs.uchicago.edu
ViewVC Help
Powered by ViewVC 1.0.0