~ubuntu-branches/ubuntu/feisty/basilisk2/feisty

« back to all changes in this revision

Viewing changes to src/uae_cpu/compiler/codegen_x86.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonas Smedegaard
  • Date: 2006-06-01 01:11:16 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060601011116-xjhegbgyfsxag5fl
Tags: 0.9.20060529-1
* New upstream CVS snapshot.
* Update local cdbs snippet copyright-check.mk:
  + Broaden scan to also look for "(c)" by default.
  + Make egrep options configurable.
  + Ignore auto-tools files.
* Bump up standards-version to 3.7.2 (no changes needed).
* Let dh_strip do the stripping (not the make install target).

Show diffs side-by-side

added added

removed removed

Lines of Context:
52
52
#define R14_INDEX 14
53
53
#define R15_INDEX 15
54
54
#endif
 
55
/* XXX this has to match X86_Reg8H_Base + 4 */
 
56
#define AH_INDEX (0x10+4+EAX_INDEX)
 
57
#define CH_INDEX (0x10+4+ECX_INDEX)
 
58
#define DH_INDEX (0x10+4+EDX_INDEX)
 
59
#define BH_INDEX (0x10+4+EBX_INDEX)
55
60
 
56
61
/* The register in which subroutines return an integer return value */
57
62
#define REG_RESULT EAX_INDEX
81
86
#define MUL_NREG1 EAX_INDEX /* %eax will hold the low 32 bits after a 32x32 mul */
82
87
#define MUL_NREG2 EDX_INDEX /* %edx will hold the high 32 bits */
83
88
 
 
89
#define STACK_ALIGN             16
 
90
#define STACK_OFFSET    sizeof(void *)
 
91
 
84
92
uae_s8 always_used[]={4,-1};
85
93
#if defined(__x86_64__)
86
94
uae_s8 can_byte[]={0,1,2,3,5,6,7,8,9,10,11,12,13,14,15,-1};
108
116
     by pushing, even though they are "saved" across function calls
109
117
*/
110
118
#if defined(__x86_64__)
111
 
/* callee-saved registers as defined by Linux/x86_64 ABI: rbx, rbp, rsp, r12 - r15 */
 
119
/* callee-saved registers as defined by Linux AMD64 ABI: rbx, rbp, rsp, r12 - r15 */
112
120
/* preserve r11 because it's generally used to hold pointers to functions */
113
121
static const uae_u8 need_to_preserve[]={0,0,0,1,0,1,0,0,0,0,0,1,1,1,1,1};
114
122
#else
115
 
static const uae_u8 need_to_preserve[]={1,1,1,1,0,1,1,1};
 
123
/* callee-saved registers as defined by System V IA-32 ABI: edi, esi, ebx, ebp */
 
124
static const uae_u8 need_to_preserve[]={0,0,0,1,0,1,1,1};
116
125
#endif
117
126
 
118
127
/* Whether classes of instructions do or don't clobber the native flags */
1187
1196
}
1188
1197
LENDFUNC(WRITE,READ,0,raw_popfl,(void))
1189
1198
 
 
1199
/* Generate floating-point instructions */
 
1200
static inline void x86_fadd_m(MEMR s)
 
1201
{
 
1202
        FADDLm(s,X86_NOREG,X86_NOREG,1);
 
1203
}
 
1204
 
1190
1205
#else
1191
1206
 
1192
1207
const bool optimize_accum               = true;
2410
2425
LOWFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s))
2411
2426
{
2412
2427
    emit_byte(0x88);
2413
 
    emit_byte(0x05+8*s);
 
2428
    emit_byte(0x05+8*(s&0xf)); /* XXX this handles %ah case (defined as 0x10+4) and others */
2414
2429
    emit_long(d);
2415
2430
}
2416
2431
LENDFUNC(NONE,WRITE,2,raw_mov_b_mr,(IMM d, R1 s))
2963
2978
}
2964
2979
LENDFUNC(WRITE,READ,0,raw_popfl,(void))
2965
2980
 
 
2981
/* Generate floating-point instructions */
 
2982
static inline void x86_fadd_m(MEMR s)
 
2983
{
 
2984
        emit_byte(0xdc);
 
2985
        emit_byte(0x05);
 
2986
        emit_long(s);
 
2987
}
 
2988
 
2966
2989
#endif
2967
2990
 
2968
2991
/*************************************************************************
3217
3240
#ifdef SAHF_SETO_PROFITABLE
3218
3241
 
3219
3242
#define FLAG_NREG1 0  /* Set to -1 if any register will do */
3220
 
 
3221
3243
static __inline__ void raw_flags_to_reg(int r)
3222
3244
{
3223
3245
  raw_lahf(0);  /* Most flags in AH */
3226
3248
  
3227
3249
#if 1   /* Let's avoid those nasty partial register stalls */
3228
3250
  //raw_mov_b_mr((uintptr)live.state[FLAGTMP].mem,r);
3229
 
  raw_mov_b_mr(((uintptr)live.state[FLAGTMP].mem)+1,r+4);
 
3251
  raw_mov_b_mr(((uintptr)live.state[FLAGTMP].mem)+1,AH_INDEX);
3230
3252
  //live.state[FLAGTMP].status=CLEAN;
3231
3253
  live.state[FLAGTMP].status=INMEM;
3232
3254
  live.state[FLAGTMP].realreg=-1;
3322
3344
        raw_mov_l_rm(target,(uintptr)live.state[r].mem);
3323
3345
}
3324
3346
 
 
3347
static __inline__ void raw_dec_sp(int off)
 
3348
{
 
3349
    if (off) raw_sub_l_ri(ESP_INDEX,off);
 
3350
}
 
3351
 
3325
3352
static __inline__ void raw_inc_sp(int off)
3326
3353
{
3327
 
    raw_add_l_ri(ESP_INDEX,off);
 
3354
    if (off) raw_add_l_ri(ESP_INDEX,off);
3328
3355
}
3329
3356
 
3330
3357
/*************************************************************************
4286
4313
}
4287
4314
LENDFUNC(NONE,NONE,2,raw_fsin_rr,(FW d, FR s))
4288
4315
 
4289
 
double one=1;
 
4316
static const double one=1;
4290
4317
LOWFUNC(NONE,NONE,2,raw_ftwotox_rr,(FW d, FR s))
4291
4318
{
4292
4319
    int ds;
4306
4333
    emit_byte(0xe1);  /* subtract rounded from original */
4307
4334
    emit_byte(0xd9);
4308
4335
    emit_byte(0xf0);  /* f2xm1 */
4309
 
    emit_byte(0xdc);
4310
 
    emit_byte(0x05);
4311
 
    emit_long((uintptr)&one);  /* Add '1' without using extra stack space */
 
4336
    x86_fadd_m((uintptr)&one);  /* Add '1' without using extra stack space */
4312
4337
    emit_byte(0xd9);
4313
4338
    emit_byte(0xfd);  /* and scale it */
4314
4339
    emit_byte(0xdd);
4340
4365
    emit_byte(0xe1);  /* subtract rounded from original */
4341
4366
    emit_byte(0xd9);
4342
4367
    emit_byte(0xf0);  /* f2xm1 */
4343
 
    emit_byte(0xdc);
4344
 
    emit_byte(0x05);
4345
 
    emit_long((uintptr)&one);  /* Add '1' without using extra stack space */
 
4368
    x86_fadd_m((uintptr)&one);  /* Add '1' without using extra stack space */
4346
4369
    emit_byte(0xd9);
4347
4370
    emit_byte(0xfd);  /* and scale it */
4348
4371
    emit_byte(0xdd);