Mercurial > hg > CbC > old > device
comparison mc-code-powerpc.c @ 779:a0f84a0a990a
float value sharing
author | Shinji KONO <kono@ie.u-ryukyu.ac.jp> |
---|---|
date | Fri, 19 Nov 2010 14:09:56 +0900 |
parents | a177c65f3e37 |
children | c5315f472912 |
comparison
equal
deleted
inserted
replaced
778:a177c65f3e37 | 779:a0f84a0a990a |
---|---|
4240 float f = d; | 4240 float f = d; |
4241 int *j = (int *)&f; | 4241 int *j = (int *)&f; |
4242 return *j; | 4242 return *j; |
4243 } | 4243 } |
4244 | 4244 |
4245 static void emit_dconst0(ValuePtr value, int lb, void *arg) | |
4246 { | |
4247 long d = (long) arg; | |
4248 printf(" \t.data\n\t.align 3\n"); | |
4249 lb=fwdlabel(); | |
4250 printf("%s%d:\n",lpfx,lb); | |
4251 if (d) { | |
4252 #if ENDIAN_D==0 | |
4253 printf("\t.long\t0x%x,0x%x\n",code_d1(value->d),code_d2(value->d)); | |
4254 #else | |
4255 printf("\t.long\t0x%x,0x%x\n",code_d2(value->d),code_d1(value->d)); | |
4256 #endif | |
4257 } else { | |
4258 printf("\t.long\t0x%x\n",code_f(value->i)); | |
4259 } | |
4260 if (output_mode==TEXT_EMIT_MODE) { | |
4261 printf(".text\n"); | |
4262 } else { | |
4263 text_mode(0); | |
4264 } | |
4265 } | |
4266 | |
4267 /* load double / float const | |
4268 we should keep what constant we have create | |
4269 */ | |
4270 | |
4245 void | 4271 void |
4246 code_dconst(int e2,int freg,int d) | 4272 code_dconst(int e2,int freg,int d) |
4247 { | 4273 { |
4248 int lb; | 4274 int lb; |
4249 double value = dcadr(e2); | 4275 Value value; |
4276 value.d = dcadr(e2); | |
4250 int r; | 4277 int r; |
4251 char *rrn,*frn; | 4278 char *rrn,*frn; |
4252 | |
4253 use_float(d,freg); | 4279 use_float(d,freg); |
4254 frn = fregister_name(freg); | 4280 frn = fregister_name(freg); |
4255 if (value==0.0) { | 4281 if (value.d==0.0) { |
4256 float_zero_lib_used=1; | 4282 float_zero_lib_used=1; |
4257 r = get_ptr_cache(&float_zero); | 4283 r = get_ptr_cache(&float_zero); |
4258 rrn = register_name(r); | 4284 rrn = register_name(r); |
4259 printf("\tlfs %s,0(%s)\n",frn,rrn); | 4285 printf("\tlfs %s,0(%s)\n",frn,rrn); |
4260 return; | 4286 return; |
4261 } | 4287 } |
4262 if (value==1.0) { | 4288 if (value.d==1.0) { |
4263 float_one_lib_used=1; | 4289 float_one_lib_used=1; |
4264 r = get_ptr_cache(&float_one); | 4290 r = get_ptr_cache(&float_one); |
4265 rrn = register_name(r); | 4291 rrn = register_name(r); |
4266 printf("\tlfs %s,0(%s)\n",frn,rrn); | 4292 printf("\tlfs %s,0(%s)\n",frn,rrn); |
4267 return; | 4293 return; |
4268 } | 4294 } |
4295 if (d) { | |
4296 sz = sizeof(double); | |
4297 } else { | |
4298 sz = sizeof(float); | |
4299 value.f = (float) value.d; | |
4300 } | |
4301 | |
4302 long d_mode = d; | |
4303 int lb = get_data_label(&value,sz,emit_dconst0, (void*) d_mode); | |
4304 | |
4269 rrn = register_name((r=get_register())); | 4305 rrn = register_name((r=get_register())); |
4270 use_reg(r); // to clear ptr cache | 4306 use_reg(r); // to clear ptr cache |
4271 printf(" \t.data\n\t.align 3\n"); | |
4272 lb=fwdlabel(); | |
4273 printf("%s%d:\n",lpfx,lb); | |
4274 if (d) { | |
4275 #if ENDIAN_D==0 | |
4276 printf("\t.long\t0x%x,0x%x\n",code_d1(value),code_d2(value)); | |
4277 #else | |
4278 printf("\t.long\t0x%x,0x%x\n",code_d2(value),code_d1(value)); | |
4279 #endif | |
4280 } else { | |
4281 printf("\t.long\t0x%x\n",code_f(value)); | |
4282 } | |
4283 if (output_mode==TEXT_EMIT_MODE) { | |
4284 printf(".text\n"); | |
4285 } else { | |
4286 text_mode(0); | |
4287 } | |
4288 code_label_value(lb,r); | 4307 code_label_value(lb,r); |
4289 if (d) { | 4308 if (d) { |
4290 printf("\tlfd %s,0(%s)\n",frn,rrn); | 4309 printf("\tlfd %s,0(%s)\n",frn,rrn); |
4291 } else { | 4310 } else { |
4292 printf("\tlfs %s,0(%s)\n",frn,rrn); | 4311 printf("\tlfs %s,0(%s)\n",frn,rrn); |