Revision a7812ae4 tcg/tcg.h

b/tcg/tcg.h
114 114
   expecially on targets with braindamaged ABIs (e.g. i386).
115 115
   We use plain int by default to avoid this runtime overhead.
116 116
   Users of tcg_gen_* don't need to know about any of this, and should
117
   treat TCGv as an opaque type.  */
117
   treat TCGv as an opaque type.
118
   In additon we do typechecking for different types of variables.  TCGv_i32
119
   and TCGv_i64 are 32/64-bit variables respectively.  TCGv and TCGv_ptr
120
   are aliases for target_ulong and host pointer sized values respectively.
121
 */
118 122

  
119 123
//#define DEBUG_TCGV 1
120 124

  
......
123 127
typedef struct
124 128
{
125 129
    int n;
126
} TCGv;
130
} TCGv_i32;
127 131

  
128
#define MAKE_TCGV(i) __extension__ \
129
  ({ TCGv make_tcgv_tmp = {i}; make_tcgv_tmp;})
130
#define GET_TCGV(t) ((t).n)
132
typedef struct
133
{
134
    int n;
135
} TCGv_i64;
136

  
137
#define MAKE_TCGV_I32(i) __extension__                  \
138
    ({ TCGv_i32 make_tcgv_tmp = {i}; make_tcgv_tmp;})
139
#define MAKE_TCGV_I64(i) __extension__                  \
140
    ({ TCGv_i64 make_tcgv_tmp = {i}; make_tcgv_tmp;})
141
#define GET_TCGV_I32(t) ((t).n)
142
#define GET_TCGV_I64(t) ((t).n)
131 143
#if TCG_TARGET_REG_BITS == 32
132
#define TCGV_HIGH(t) MAKE_TCGV(GET_TCGV(t) + 1)
144
#define TCGV_LOW(t) MAKE_TCGV_I32(GET_TCGV_I64(t))
145
#define TCGV_HIGH(t) MAKE_TCGV_I32(GET_TCGV_I64(t) + 1)
133 146
#endif
134 147

  
135 148
#else /* !DEBUG_TCGV */
136 149

  
137
typedef int TCGv;
138
#define MAKE_TCGV(x) (x)
139
#define GET_TCGV(t) (t)
150
typedef int TCGv_i32;
151
typedef int TCGv_i64;
152
#define MAKE_TCGV_I32(x) (x)
153
#define MAKE_TCGV_I64(x) (x)
154
#define GET_TCGV_I32(t) (t)
155
#define GET_TCGV_I64(t) (t)
140 156
#if TCG_TARGET_REG_BITS == 32
157
#define TCGV_LOW(t) (t)
141 158
#define TCGV_HIGH(t) ((t) + 1)
142 159
#endif
143 160

  
144 161
#endif /* DEBUG_TCGV */
145 162

  
146 163
/* Dummy definition to avoid compiler warnings.  */
147
#define TCGV_UNUSED(x) x = MAKE_TCGV(-1)
164
#define TCGV_UNUSED_I32(x) x = MAKE_TCGV_I32(-1)
165
#define TCGV_UNUSED_I64(x) x = MAKE_TCGV_I64(-1)
148 166

  
149 167
/* call flags */
150 168
#define TCG_CALL_TYPE_MASK      0x000f
......
158 176
#define TCG_CALL_PURE           0x0010 
159 177

  
160 178
/* used to align parameters */
161
#define TCG_CALL_DUMMY_TCGV     MAKE_TCGV(-1)
179
#define TCG_CALL_DUMMY_TCGV     MAKE_TCGV_I32(-1)
162 180
#define TCG_CALL_DUMMY_ARG      ((TCGArg)(-1))
163 181

  
164 182
typedef enum {
......
301 319

  
302 320
void tcg_set_frame(TCGContext *s, int reg,
303 321
                   tcg_target_long start, tcg_target_long size);
304
TCGv tcg_global_reg_new(TCGType type, int reg, const char *name);
305
TCGv tcg_global_reg2_new_hack(TCGType type, int reg1, int reg2, 
306
                              const char *name);
307
TCGv tcg_global_mem_new(TCGType type, int reg, tcg_target_long offset,
308
                        const char *name);
309
TCGv tcg_temp_new_internal(TCGType type, int temp_local);
310
static inline TCGv tcg_temp_new(TCGType type)
322
TCGv_i64 tcg_global_reg2_new_hack(TCGType type, int reg1, int reg2,
323
                                  const char *name);
324

  
325
TCGv_i32 tcg_global_reg_new_i32(int reg, const char *name);
326
TCGv_i32 tcg_global_mem_new_i32(int reg, tcg_target_long offset,
327
                                const char *name);
328
TCGv_i32 tcg_temp_new_internal_i32(int temp_local);
329
static inline TCGv_i32 tcg_temp_new_i32(void)
330
{
331
    return tcg_temp_new_internal_i32(0);
332
}
333
static inline TCGv_i32 tcg_temp_local_new_i32(void)
334
{
335
    return tcg_temp_new_internal_i32(1);
336
}
337
void tcg_temp_free_i32(TCGv_i32 arg);
338
char *tcg_get_arg_str_i32(TCGContext *s, char *buf, int buf_size, TCGv_i32 arg);
339

  
340
TCGv_i64 tcg_global_reg_new_i64(int reg, const char *name);
341
TCGv_i64 tcg_global_mem_new_i64(int reg, tcg_target_long offset,
342
                                const char *name);
343
TCGv_i64 tcg_temp_new_internal_i64(int temp_local);
344
static inline TCGv_i64 tcg_temp_new_i64(void)
311 345
{
312
    return tcg_temp_new_internal(type, 0);
346
    return tcg_temp_new_internal_i64(0);
313 347
}
314
static inline TCGv tcg_temp_local_new(TCGType type)
348
static inline TCGv_i64 tcg_temp_local_new_i64(void)
315 349
{
316
    return tcg_temp_new_internal(type, 1);
350
    return tcg_temp_new_internal_i64(1);
317 351
}
318
void tcg_temp_free(TCGv arg);
319
char *tcg_get_arg_str(TCGContext *s, char *buf, int buf_size, TCGv arg);
352
void tcg_temp_free_i64(TCGv_i64 arg);
353
char *tcg_get_arg_str_i64(TCGContext *s, char *buf, int buf_size, TCGv_i64 arg);
354

  
320 355
void tcg_dump_info(FILE *f,
321 356
                   int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
322 357

  
......
370 405

  
371 406
void tcg_add_target_add_op_defs(const TCGTargetOpDef *tdefs);
372 407

  
373
void tcg_gen_call(TCGContext *s, TCGv func, unsigned int flags,
374
                  unsigned int nb_rets, const TCGv *rets,
375
                  unsigned int nb_params, const TCGv *args1);
376
void tcg_gen_shifti_i64(TCGv ret, TCGv arg1, 
377
                        int c, int right, int arith);
378

  
379
/* only used for debugging purposes */
380
void tcg_register_helper(void *func, const char *name);
381
#define TCG_HELPER(func) tcg_register_helper(func, #func)
382
const char *tcg_helper_get_name(TCGContext *s, void *func);
383
void tcg_dump_ops(TCGContext *s, FILE *outfile);
384

  
385
void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf);
386
TCGv tcg_const_i32(int32_t val);
387
TCGv tcg_const_i64(int64_t val);
388
TCGv tcg_const_local_i32(int32_t val);
389
TCGv tcg_const_local_i64(int64_t val);
390

  
391 408
#if TCG_TARGET_REG_BITS == 32
392 409
#define tcg_const_ptr tcg_const_i32
393 410
#define tcg_add_ptr tcg_add_i32
394 411
#define tcg_sub_ptr tcg_sub_i32
412
#define TCGv_ptr TCGv_i32
413
#define GET_TCGV_PTR GET_TCGV_I32
414
#define tcg_global_reg_new_ptr tcg_global_reg_new_i32
415
#define tcg_global_mem_new_ptr tcg_global_mem_new_i32
416
#define tcg_temp_new_ptr tcg_temp_new_i32
417
#define tcg_temp_free_ptr tcg_temp_free_i32
395 418
#else
396 419
#define tcg_const_ptr tcg_const_i64
397 420
#define tcg_add_ptr tcg_add_i64
398 421
#define tcg_sub_ptr tcg_sub_i64
422
#define TCGv_ptr TCGv_i64
423
#define GET_TCGV_PTR GET_TCGV_I64
424
#define tcg_global_reg_new_ptr tcg_global_reg_new_i64
425
#define tcg_global_mem_new_ptr tcg_global_mem_new_i64
426
#define tcg_temp_new_ptr tcg_temp_new_i64
427
#define tcg_temp_free_ptr tcg_temp_free_i64
399 428
#endif
400 429

  
430
void tcg_gen_callN(TCGContext *s, TCGv_ptr func, unsigned int flags,
431
                   int sizemask, TCGArg ret, int nargs, TCGArg *args);
432

  
433
void tcg_gen_shifti_i64(TCGv_i64 ret, TCGv_i64 arg1,
434
                        int c, int right, int arith);
435

  
436
/* only used for debugging purposes */
437
void tcg_register_helper(void *func, const char *name);
438
const char *tcg_helper_get_name(TCGContext *s, void *func);
439
void tcg_dump_ops(TCGContext *s, FILE *outfile);
440

  
441
void dump_ops(const uint16_t *opc_buf, const TCGArg *opparam_buf);
442
TCGv_i32 tcg_const_i32(int32_t val);
443
TCGv_i64 tcg_const_i64(int64_t val);
444
TCGv_i32 tcg_const_local_i32(int32_t val);
445
TCGv_i64 tcg_const_local_i64(int64_t val);
446

  
401 447
void tcg_out_reloc(TCGContext *s, uint8_t *code_ptr, int type, 
402 448
                   int label_index, long addend);
403 449
const TCGArg *tcg_gen_code_op(TCGContext *s, int opc, const TCGArg *args1,

Also available in: Unified diff