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 3055, Tue Jun 3 06:55:14 2008 UTC revision 3062, Wed Jun 4 06:59:52 2008 UTC
# Line 7  Line 7 
7  extern void varargs (void* fun, void* args, int);  extern void varargs (void* fun, void* args, int);
8    
9  typedef struct {  typedef struct {
10    void* val;    long long val;
11    void* kind;    long long kind;
12    void* loc;    long long loc;
13    void* ty;    long long ty;
14  }  zipped_arg_t;  }  zipped_arg_t;
15    
16  typedef struct varargs_s {  typedef struct varargs_s {
17    zipped_arg_t* hd;    zipped_arg_t* hd;
18      int pad;
19    struct varargs_s* tl;    struct varargs_s* tl;
20  } varargs_t;  } varargs_t;
21    
# Line 35  Line 36 
36  #define N_ARGS 2  #define N_ARGS 2
37  #define STK 2  #define STK 2
38  #define FSTK 3  #define FSTK 3
39    #define OFF(i) (i*4)
40    
41  int alignb (int n) {  int alignb (int n) {
42    n += 2;    n += 2;
43    n *= sizeof(void*);    n *= sizeof(long long*);
44    n += 16-(n%16);    n += 16-(n%16);
45    return n-(2*sizeof(void*));    return n-(2*sizeof(void*));
46  }  }
# Line 55  Line 57 
57      args[i]->tl = args[i+1];      args[i]->tl = args[i+1];
58    
59    args[0]->hd = NEW(zipped_arg_t);    args[0]->hd = NEW(zipped_arg_t);
60    args[0]->hd->val = (void*)"arg1=%f\n";    args[0]->hd->val = (long long)"arg1=%d\n";
61    args[0]->hd->kind = (void*)STK;    args[0]->hd->kind = (long long)STK;
62    args[0]->hd->loc = (void*)(0*4);    args[0]->hd->loc = (long long)OFF(0);
63      args[0]->hd->ty = (long long)32;
   float f = 3.14f;  
   void** x = (void*)&f;  
   printf("%f\n",*(float*)x);  
64    
65    args[1]->hd = NEW(zipped_arg_t);    args[1]->hd = NEW(zipped_arg_t);
66    args[1]->hd->val = *x;    args[1]->hd->val = (long long)69;
67    args[1]->hd->kind = (void*)FSTK;    args[1]->hd->kind = (long long)STK;
68    args[1]->hd->loc = (void*)(1*4);    args[1]->hd->loc = (long long)OFF(1);
69    args[1]->hd->ty = (void*)32;    args[1]->hd->ty = (long long)32;
70    
71    varargs(Say, args[0], alignb(N_ARGS));    varargs(Say, args[0], 16);
72    
73    return 0;    return 0;
74  }  }

Legend:
Removed from v.3055  
changed lines
  Added in v.3062

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