tcg-op.c (35c653c4029794f67a523191941104fe12f2b22d) | tcg-op.c (7b8801071951c55dc506c1fca8b40ba292a28d6e) |
---|---|
1/* 2 * Tiny Code Generator for QEMU 3 * 4 * Copyright (c) 2008 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 2945 unchanged lines hidden (view full) --- 2954 MemOp orig_memop; 2955 MemOpIdx oi; 2956 2957 tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); 2958 memop = tcg_canonicalize_memop(memop, 0, 0); 2959 oi = make_memop_idx(memop, idx); 2960 2961 orig_memop = memop; | 1/* 2 * Tiny Code Generator for QEMU 3 * 4 * Copyright (c) 2008 Fabrice Bellard 5 * 6 * Permission is hereby granted, free of charge, to any person obtaining a copy 7 * of this software and associated documentation files (the "Software"), to deal 8 * in the Software without restriction, including without limitation the rights --- 2945 unchanged lines hidden (view full) --- 2954 MemOp orig_memop; 2955 MemOpIdx oi; 2956 2957 tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); 2958 memop = tcg_canonicalize_memop(memop, 0, 0); 2959 oi = make_memop_idx(memop, idx); 2960 2961 orig_memop = memop; |
2962 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | 2962 if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) { |
2963 memop &= ~MO_BSWAP; 2964 /* The bswap primitive benefits from zero-extended input. */ 2965 if ((memop & MO_SSIZE) == MO_SW) { 2966 memop &= ~MO_SIGN; 2967 } 2968 } 2969 2970 addr = plugin_prep_mem_callbacks(addr); --- 20 unchanged lines hidden (view full) --- 2991{ 2992 TCGv_i32 swap = NULL; 2993 MemOpIdx oi; 2994 2995 tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); 2996 memop = tcg_canonicalize_memop(memop, 0, 1); 2997 oi = make_memop_idx(memop, idx); 2998 | 2963 memop &= ~MO_BSWAP; 2964 /* The bswap primitive benefits from zero-extended input. */ 2965 if ((memop & MO_SSIZE) == MO_SW) { 2966 memop &= ~MO_SIGN; 2967 } 2968 } 2969 2970 addr = plugin_prep_mem_callbacks(addr); --- 20 unchanged lines hidden (view full) --- 2991{ 2992 TCGv_i32 swap = NULL; 2993 MemOpIdx oi; 2994 2995 tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); 2996 memop = tcg_canonicalize_memop(memop, 0, 1); 2997 oi = make_memop_idx(memop, idx); 2998 |
2999 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | 2999 if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) { |
3000 swap = tcg_temp_ebb_new_i32(); 3001 switch (memop & MO_SIZE) { 3002 case MO_16: 3003 tcg_gen_bswap16_i32(swap, val, 0); 3004 break; 3005 case MO_32: 3006 tcg_gen_bswap32_i32(swap, val); 3007 break; --- 32 unchanged lines hidden (view full) --- 3040 return; 3041 } 3042 3043 tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); 3044 memop = tcg_canonicalize_memop(memop, 1, 0); 3045 oi = make_memop_idx(memop, idx); 3046 3047 orig_memop = memop; | 3000 swap = tcg_temp_ebb_new_i32(); 3001 switch (memop & MO_SIZE) { 3002 case MO_16: 3003 tcg_gen_bswap16_i32(swap, val, 0); 3004 break; 3005 case MO_32: 3006 tcg_gen_bswap32_i32(swap, val); 3007 break; --- 32 unchanged lines hidden (view full) --- 3040 return; 3041 } 3042 3043 tcg_gen_req_mo(TCG_MO_LD_LD | TCG_MO_ST_LD); 3044 memop = tcg_canonicalize_memop(memop, 1, 0); 3045 oi = make_memop_idx(memop, idx); 3046 3047 orig_memop = memop; |
3048 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | 3048 if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) { |
3049 memop &= ~MO_BSWAP; 3050 /* The bswap primitive benefits from zero-extended input. */ 3051 if ((memop & MO_SIGN) && (memop & MO_SIZE) < MO_64) { 3052 memop &= ~MO_SIGN; 3053 } 3054 } 3055 3056 addr = plugin_prep_mem_callbacks(addr); --- 29 unchanged lines hidden (view full) --- 3086 tcg_gen_qemu_st_i32(TCGV_LOW(val), addr, idx, memop); 3087 return; 3088 } 3089 3090 tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); 3091 memop = tcg_canonicalize_memop(memop, 1, 1); 3092 oi = make_memop_idx(memop, idx); 3093 | 3049 memop &= ~MO_BSWAP; 3050 /* The bswap primitive benefits from zero-extended input. */ 3051 if ((memop & MO_SIGN) && (memop & MO_SIZE) < MO_64) { 3052 memop &= ~MO_SIGN; 3053 } 3054 } 3055 3056 addr = plugin_prep_mem_callbacks(addr); --- 29 unchanged lines hidden (view full) --- 3086 tcg_gen_qemu_st_i32(TCGV_LOW(val), addr, idx, memop); 3087 return; 3088 } 3089 3090 tcg_gen_req_mo(TCG_MO_LD_ST | TCG_MO_ST_ST); 3091 memop = tcg_canonicalize_memop(memop, 1, 1); 3092 oi = make_memop_idx(memop, idx); 3093 |
3094 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (memop & MO_BSWAP)) { | 3094 if ((memop & MO_BSWAP) && !tcg_target_has_memory_bswap(memop)) { |
3095 swap = tcg_temp_ebb_new_i64(); 3096 switch (memop & MO_SIZE) { 3097 case MO_16: 3098 tcg_gen_bswap16_i64(swap, val, 0); 3099 break; 3100 case MO_32: 3101 tcg_gen_bswap32_i64(swap, val, 0); 3102 break; --- 49 unchanged lines hidden (view full) --- 3152 3153static void canonicalize_memop_i128_as_i64(MemOp ret[2], MemOp orig) 3154{ 3155 MemOp mop_1 = orig, mop_2; 3156 3157 tcg_debug_assert((orig & MO_SIZE) == MO_128); 3158 tcg_debug_assert((orig & MO_SIGN) == 0); 3159 | 3095 swap = tcg_temp_ebb_new_i64(); 3096 switch (memop & MO_SIZE) { 3097 case MO_16: 3098 tcg_gen_bswap16_i64(swap, val, 0); 3099 break; 3100 case MO_32: 3101 tcg_gen_bswap32_i64(swap, val, 0); 3102 break; --- 49 unchanged lines hidden (view full) --- 3152 3153static void canonicalize_memop_i128_as_i64(MemOp ret[2], MemOp orig) 3154{ 3155 MemOp mop_1 = orig, mop_2; 3156 3157 tcg_debug_assert((orig & MO_SIZE) == MO_128); 3158 tcg_debug_assert((orig & MO_SIGN) == 0); 3159 |
3160 /* Use a memory ordering implemented by the host. */ 3161 if (!TCG_TARGET_HAS_MEMORY_BSWAP && (orig & MO_BSWAP)) { 3162 mop_1 &= ~MO_BSWAP; 3163 } 3164 | |
3165 /* Reduce the size to 64-bit. */ 3166 mop_1 = (mop_1 & ~MO_SIZE) | MO_64; 3167 3168 /* Retain the alignment constraints of the original. */ 3169 switch (orig & MO_AMASK) { 3170 case MO_UNALN: 3171 case MO_ALIGN_2: 3172 case MO_ALIGN_4: --- 13 unchanged lines hidden (view full) --- 3186 case MO_ALIGN_32: 3187 case MO_ALIGN_64: 3188 /* Second has 8-byte alignment; first retains original. */ 3189 mop_2 = (mop_1 & ~MO_AMASK) | MO_ALIGN; 3190 break; 3191 default: 3192 g_assert_not_reached(); 3193 } | 3160 /* Reduce the size to 64-bit. */ 3161 mop_1 = (mop_1 & ~MO_SIZE) | MO_64; 3162 3163 /* Retain the alignment constraints of the original. */ 3164 switch (orig & MO_AMASK) { 3165 case MO_UNALN: 3166 case MO_ALIGN_2: 3167 case MO_ALIGN_4: --- 13 unchanged lines hidden (view full) --- 3181 case MO_ALIGN_32: 3182 case MO_ALIGN_64: 3183 /* Second has 8-byte alignment; first retains original. */ 3184 mop_2 = (mop_1 & ~MO_AMASK) | MO_ALIGN; 3185 break; 3186 default: 3187 g_assert_not_reached(); 3188 } |
3189 3190 /* Use a memory ordering implemented by the host. */ 3191 if ((orig & MO_BSWAP) && !tcg_target_has_memory_bswap(mop_1)) { 3192 mop_1 &= ~MO_BSWAP; 3193 mop_2 &= ~MO_BSWAP; 3194 } 3195 |
|
3194 ret[0] = mop_1; 3195 ret[1] = mop_2; 3196} 3197 3198#if TARGET_LONG_BITS == 64 3199#define tcg_temp_ebb_new tcg_temp_ebb_new_i64 3200#else 3201#define tcg_temp_ebb_new tcg_temp_ebb_new_i32 --- 556 unchanged lines hidden --- | 3196 ret[0] = mop_1; 3197 ret[1] = mop_2; 3198} 3199 3200#if TARGET_LONG_BITS == 64 3201#define tcg_temp_ebb_new tcg_temp_ebb_new_i64 3202#else 3203#define tcg_temp_ebb_new tcg_temp_ebb_new_i32 --- 556 unchanged lines hidden --- |