/[gxemul]/trunk/src/cpus/cpu_alpha_instr_loadstore.c
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /trunk/src/cpus/cpu_alpha_instr_loadstore.c

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

revision 14 by dpavlin, Mon Oct 8 16:18:51 2007 UTC revision 24 by dpavlin, Mon Oct 8 16:19:56 2007 UTC
# Line 1  Line 1 
1  /*  /*
2   *  Copyright (C) 2005  Anders Gavare.  All rights reserved.   *  Copyright (C) 2005-2006  Anders Gavare.  All rights reserved.
3   *   *
4   *  Redistribution and use in source and binary forms, with or without   *  Redistribution and use in source and binary forms, with or without
5   *  modification, are permitted provided that the following conditions are met:   *  modification, are permitted provided that the following conditions are met:
# Line 25  Line 25 
25   *  SUCH DAMAGE.   *  SUCH DAMAGE.
26   *   *
27   *   *
28   *  $Id: cpu_alpha_instr_loadstore.c,v 1.1 2005/08/29 14:36:41 debug Exp $   *  $Id: cpu_alpha_instr_loadstore.c,v 1.4 2006/04/22 18:28:43 debug Exp $
29   *   *
30   *  Alpha load/store instructions.  (Included from cpu_alpha_instr_inc.c.)   *  Alpha load/store instructions.  (Included from cpu_alpha_instr_inc.c.)
31   *   *
# Line 79  static void LS_GENERIC_N(struct cpu *cpu Line 79  static void LS_GENERIC_N(struct cpu *cpu
79          data_x += (data[1] << 8);          data_x += (data[1] << 8);
80  #ifndef LS_W  #ifndef LS_W
81          data_x += (data[2] << 16);          data_x += (data[2] << 16);
82          data_x += (data[3] << 24);          data_x += ((uint64_t)data[3] << 24);
83  #ifdef LS_L  #ifdef LS_L
84          data_x = (int64_t)(int32_t)data_x;          data_x = (int64_t)(int32_t)data_x;
85  #endif  #endif
# Line 130  static void LS_GENERIC_N(struct cpu *cpu Line 130  static void LS_GENERIC_N(struct cpu *cpu
130    
131  static void LS_N(struct cpu *cpu, struct alpha_instr_call *ic)  static void LS_N(struct cpu *cpu, struct alpha_instr_call *ic)
132  {  {
133          int first, a, b, c;          unsigned char *page;
134          uint64_t addr;          uint64_t addr = (*((uint64_t *)ic->arg[1]))
   
         addr = (*((uint64_t *)ic->arg[1]))  
135  #ifndef LS_IGNORE_OFFSET  #ifndef LS_IGNORE_OFFSET
136              + (int32_t)ic->arg[2]              + (int32_t)ic->arg[2]
137  #endif  #endif
138              ;              ;
139    
140            const uint32_t mask1 = (1 << DYNTRANS_L1N) - 1;
141            const uint32_t mask2 = (1 << DYNTRANS_L2N) - 1;
142            const uint32_t mask3 = (1 << DYNTRANS_L3N) - 1;
143            uint32_t x1, x2, x3, c;
144            struct DYNTRANS_L2_64_TABLE *l2;
145            struct DYNTRANS_L3_64_TABLE *l3;
146            x1 = (addr >> (64-DYNTRANS_L1N)) & mask1;
147            x2 = (addr >> (64-DYNTRANS_L1N-DYNTRANS_L2N)) & mask2;
148            x3 = (addr >> (64-DYNTRANS_L1N-DYNTRANS_L2N-DYNTRANS_L3N)) & mask3;
149            /*  fatal("X3: addr=%016"PRIx64" x1=%x x2=%x x3=%x\n",
150                (uint64_t) addr, (int) x1, (int) x2, (int) x3);  */
151            l2 = cpu->cd.DYNTRANS_ARCH.l1_64[x1];
152            /*  fatal("  l2 = %p\n", l2);  */
153            l3 = l2->l3[x2];
154            /*  fatal("  l3 = %p\n", l3);  */
155    #ifdef LS_LOAD
156            page = l3->host_load[x3];
157    #else
158            page = l3->host_store[x3];
159    #endif
160    
161  #ifdef LS_UNALIGNED  #ifdef LS_UNALIGNED
162          addr &= ~7;          addr &= ~7;
163  #endif  #endif
# Line 161  static void LS_N(struct cpu *cpu, struct Line 180  static void LS_N(struct cpu *cpu, struct
180  #endif  #endif
181  #endif  #endif
182    
         first = addr >> ALPHA_TOPSHIFT;  
         a = (addr >> ALPHA_LEVEL0_SHIFT) & (ALPHA_LEVEL0 - 1);  
         b = (addr >> ALPHA_LEVEL1_SHIFT) & (ALPHA_LEVEL1 - 1);  
183          c = addr & 8191;          c = addr & 8191;
184    
185  #ifdef LS_ALIGN_CHECK  #ifdef LS_ALIGN_CHECK
# Line 186  static void LS_N(struct cpu *cpu, struct Line 202  static void LS_N(struct cpu *cpu, struct
202  #endif  #endif
203  #endif  #endif
204    
205          if (first == 0) {          if (page != NULL) {
                 struct alpha_vph_page *vph_p;  
                 unsigned char *page;  
                 vph_p = cpu->cd.alpha.vph_table0[a];  
 #ifdef LS_LOAD  
                 page = vph_p->host_load[b];  
 #else  
                 page = vph_p->host_store[b];  
 #endif  
                 if (page != NULL) {  
 #ifdef LS_LOAD  
 #ifdef HOST_BIG_ENDIAN  
                         uint64_t data_x;  
                         data_x = page[c];  
 #ifndef LS_B  
                         data_x += (page[c+1] << 8);  
 #ifndef LS_W  
                         data_x += (page[c+2] << 16);  
                         data_x += (page[c+3] << 24);  
 #ifndef LS_L  
                         data_x += ((uint64_t)page[c+4] << 32);  
                         data_x += ((uint64_t)page[c+5] << 40);  
                         data_x += ((uint64_t)page[c+6] << 48);  
                         data_x += ((uint64_t)page[c+7] << 56);  
 #endif  
 #endif  
 #endif  
 #ifdef LS_L  
                         *((uint64_t *)ic->arg[0]) = (int64_t)(int32_t)data_x;  
 #else  
                         *((uint64_t *)ic->arg[0]) = data_x;  
 #endif  
 #else  
 #ifdef LS_B  
                         *((uint64_t *)ic->arg[0]) = page[c];  
 #endif  
 #ifdef LS_W  
                         uint16_t d = *((uint16_t *) (page + c));  
                         *((uint64_t *)ic->arg[0]) = d;  
 #endif  
 #ifdef LS_L  
                         int32_t d = *((int32_t *) (page + c));  
                         *((uint64_t *)ic->arg[0]) = (int64_t)d;  
 #endif  
 #ifdef LS_Q  
                         uint64_t d = *((uint64_t *) (page + c));  
                         *((uint64_t *)ic->arg[0]) = d;  
 #endif  
 #endif  
 #else  
                         /*  Store:  */  
 #ifdef HOST_BIG_ENDIAN  
                         uint64_t data_x = *((uint64_t *)ic->arg[0]);  
                         page[c] = data_x;  
 #ifndef LS_B  
                         page[c+1] = data_x >> 8;  
 #ifndef LS_W  
                         page[c+2] = data_x >> 16;  
                         page[c+3] = data_x >> 24;  
 #ifndef LS_L  
                         page[c+4] = data_x >> 32;  
                         page[c+5] = data_x >> 40;  
                         page[c+6] = data_x >> 48;  
                         page[c+7] = data_x >> 56;  
 #endif  
 #endif  
 #endif  
 #else  
                         /*  Native byte order:  */  
 #ifdef LS_B  
                         page[c] = *((uint64_t *)ic->arg[0]);  
 #endif  
 #ifdef LS_W  
                         uint32_t d = *((uint64_t *)ic->arg[0]);  
                         *((uint16_t *) (page + c)) = d;  
 #endif  
 #ifdef LS_L  
                         uint32_t d = *((uint64_t *)ic->arg[0]);  
                         *((uint32_t *) (page + c)) = d;  
 #endif  
 #ifdef LS_Q  
                         uint64_t d = *((uint64_t *)ic->arg[0]);  
                         *((uint64_t *) (page + c)) = d;  
 #endif  
 #endif  
   
 #ifdef LS_LLSC  
 #ifndef LS_LOAD  
                         *((uint64_t *)ic->arg[0]) = 1;  
 #endif  
 #endif  
   
 #endif  /*  !LS_LOAD  */  
                 } else  
                         LS_GENERIC_N(cpu, ic);  
         } else if (first == ALPHA_TOP_KERNEL) {  
                 struct alpha_vph_page *vph_p;  
                 unsigned char *page;  
                 vph_p = cpu->cd.alpha.vph_table0_kernel[a];  
 #ifdef LS_LOAD  
                 page = vph_p->host_load[b];  
 #else  
                 page = vph_p->host_store[b];  
 #endif  
                 if (page != NULL) {  
206  #ifdef LS_LOAD  #ifdef LS_LOAD
207  #ifdef HOST_BIG_ENDIAN  #ifdef HOST_BIG_ENDIAN
208                          uint64_t data_x;                  uint64_t data_x;
209                          data_x = page[c];                  data_x = page[c];
210  #ifndef LS_B  #ifndef LS_B
211                          data_x += (page[c+1] << 8);                  data_x += (page[c+1] << 8);
212  #ifndef LS_W  #ifndef LS_W
213                          data_x += (page[c+2] << 16);                  data_x += (page[c+2] << 16);
214                          data_x += (page[c+3] << 24);                  data_x += ((uint64_t)page[c+3] << 24);
215  #ifndef LS_L  #ifndef LS_L
216                          data_x += ((uint64_t)page[c+4] << 32);                  data_x += ((uint64_t)page[c+4] << 32);
217                          data_x += ((uint64_t)page[c+5] << 40);                  data_x += ((uint64_t)page[c+5] << 40);
218                          data_x += ((uint64_t)page[c+6] << 48);                  data_x += ((uint64_t)page[c+6] << 48);
219                          data_x += ((uint64_t)page[c+7] << 56);                  data_x += ((uint64_t)page[c+7] << 56);
220  #endif  #endif
221  #endif  #endif
222  #endif  #endif
223  #ifdef LS_L  #ifdef LS_L
224                          *((uint64_t *)ic->arg[0]) = (int64_t)(int32_t)data_x;                  *((uint64_t *)ic->arg[0]) = (int64_t)(int32_t)data_x;
225  #else  #else
226                          *((uint64_t *)ic->arg[0]) = data_x;                  *((uint64_t *)ic->arg[0]) = data_x;
227  #endif  #endif
228  #else  #else
229  #ifdef LS_B  #ifdef LS_B
230                          *((uint64_t *)ic->arg[0]) = page[c];                  *((uint64_t *)ic->arg[0]) = page[c];
231  #endif  #endif
232  #ifdef LS_W  #ifdef LS_W
233                          uint16_t d = *((uint16_t *) (page + c));                  uint16_t d = *((uint16_t *) (page + c));
234                          *((uint64_t *)ic->arg[0]) = d;                  *((uint64_t *)ic->arg[0]) = d;
235  #endif  #endif
236  #ifdef LS_L  #ifdef LS_L
237                          int32_t d = *((int32_t *) (page + c));                  int32_t d = *((int32_t *) (page + c));
238                          *((uint64_t *)ic->arg[0]) = (int64_t)d;                  *((uint64_t *)ic->arg[0]) = (int64_t)d;
239  #endif  #endif
240  #ifdef LS_Q  #ifdef LS_Q
241                          uint64_t d = *((uint64_t *) (page + c));                  uint64_t d = *((uint64_t *) (page + c));
242                          *((uint64_t *)ic->arg[0]) = d;                  *((uint64_t *)ic->arg[0]) = d;
243  #endif  #endif
244  #endif  #endif
245  #else  #else
246                          /*  Store:  */                  /*  Store:  */
247  #ifdef HOST_BIG_ENDIAN  #ifdef HOST_BIG_ENDIAN
248                          uint64_t data_x = *((uint64_t *)ic->arg[0]);                  uint64_t data_x = *((uint64_t *)ic->arg[0]);
249                          page[c] = data_x;                  page[c] = data_x;
250  #ifndef LS_B  #ifndef LS_B
251                          page[c+1] = data_x >> 8;                  page[c+1] = data_x >> 8;
252  #ifndef LS_W  #ifndef LS_W
253                          page[c+2] = data_x >> 16;                  page[c+2] = data_x >> 16;
254                          page[c+3] = data_x >> 24;                  page[c+3] = data_x >> 24;
255  #ifndef LS_L  #ifndef LS_L
256                          page[c+4] = data_x >> 32;                  page[c+4] = data_x >> 32;
257                          page[c+5] = data_x >> 40;                  page[c+5] = data_x >> 40;
258                          page[c+6] = data_x >> 48;                  page[c+6] = data_x >> 48;
259                          page[c+7] = data_x >> 56;                  page[c+7] = data_x >> 56;
260  #endif  #endif
261  #endif  #endif
262  #endif  #endif
263  #else  #else
264                          /*  Native byte order:  */                  /*  Native byte order:  */
265  #ifdef LS_B  #ifdef LS_B
266                          page[c] = *((uint64_t *)ic->arg[0]);                  page[c] = *((uint64_t *)ic->arg[0]);
267  #endif  #endif
268  #ifdef LS_W  #ifdef LS_W
269                          uint32_t d = *((uint64_t *)ic->arg[0]);                  uint32_t d = *((uint64_t *)ic->arg[0]);
270                          *((uint16_t *) (page + c)) = d;                  *((uint16_t *) (page + c)) = d;
271  #endif  #endif
272  #ifdef LS_L  #ifdef LS_L
273                          uint32_t d = *((uint64_t *)ic->arg[0]);                  uint32_t d = *((uint64_t *)ic->arg[0]);
274                          *((uint32_t *) (page + c)) = d;                  *((uint32_t *) (page + c)) = d;
275  #endif  #endif
276  #ifdef LS_Q  #ifdef LS_Q
277                          uint64_t d = *((uint64_t *)ic->arg[0]);                  uint64_t d = *((uint64_t *)ic->arg[0]);
278                          *((uint64_t *) (page + c)) = d;                  *((uint64_t *) (page + c)) = d;
279  #endif  #endif
280  #endif  #endif
281    
282  #ifdef LS_LLSC  #ifdef LS_LLSC
283  #ifndef LS_LOAD  #ifndef LS_LOAD
284                          *((uint64_t *)ic->arg[0]) = 1;                  *((uint64_t *)ic->arg[0]) = 1;
285  #endif  #endif
286  #endif  #endif
287    
288  #endif  /*  !LS_LOAD  */  #endif  /*  !LS_LOAD  */
                 } else  
                         LS_GENERIC_N(cpu, ic);  
289          } else          } else
290                  LS_GENERIC_N(cpu, ic);                  LS_GENERIC_N(cpu, ic);
291  }  }

Legend:
Removed from v.14  
changed lines
  Added in v.24

  ViewVC Help
Powered by ViewVC 1.1.26