diff options
author | Nicolai Hähnle <[email protected]> | 2016-04-29 22:15:48 -0500 |
---|---|---|
committer | Nicolai Hähnle <[email protected]> | 2016-05-07 16:46:59 -0500 |
commit | 60d2fc233bc7f15120f72119f9af678175a9b40d (patch) | |
tree | 4e5add7d0a162d04f6ff5d8bd7457f0725ce89bc /src/gallium/drivers/radeon | |
parent | 62b7958cd0ec03ff1e15144f0104728458621d1d (diff) |
gallium/radeon: clean left-shift undefined behavior
Shifting into the sign bit of a signed int is undefined behavior.
Unfortunately, there are potentially many places where this happens using
the register macros.
This commit is the result of running
sed -ie "s/(((\(\w\+\)) & 0x\(\w\+\)) << \(\w\+\))/(((unsigned)(\1) \& 0x\2) << \3)/g"
on all header files in gallium/{r600,radeon,radeonsi}.
Reviewed-by: Marek Olšák <[email protected]>
Diffstat (limited to 'src/gallium/drivers/radeon')
-rw-r--r-- | src/gallium/drivers/radeon/r600_pipe_common.h | 8 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/r600d_common.h | 108 | ||||
-rw-r--r-- | src/gallium/drivers/radeon/radeon_uvd.h | 6 |
3 files changed, 61 insertions, 61 deletions
diff --git a/src/gallium/drivers/radeon/r600_pipe_common.h b/src/gallium/drivers/radeon/r600_pipe_common.h index 74eefbb8fc5..c313bc947b6 100644 --- a/src/gallium/drivers/radeon/r600_pipe_common.h +++ b/src/gallium/drivers/radeon/r600_pipe_common.h @@ -762,9 +762,9 @@ r600_get_sampler_view_priority(struct r600_resource *res) /* For MSAA sample positions. */ #define FILL_SREG(s0x, s0y, s1x, s1y, s2x, s2y, s3x, s3y) \ - (((s0x) & 0xf) | (((s0y) & 0xf) << 4) | \ - (((s1x) & 0xf) << 8) | (((s1y) & 0xf) << 12) | \ - (((s2x) & 0xf) << 16) | (((s2y) & 0xf) << 20) | \ - (((s3x) & 0xf) << 24) | (((s3y) & 0xf) << 28)) + (((s0x) & 0xf) | (((unsigned)(s0y) & 0xf) << 4) | \ + (((unsigned)(s1x) & 0xf) << 8) | (((unsigned)(s1y) & 0xf) << 12) | \ + (((unsigned)(s2x) & 0xf) << 16) | (((unsigned)(s2y) & 0xf) << 20) | \ + (((unsigned)(s3x) & 0xf) << 24) | (((unsigned)(s3y) & 0xf) << 28)) #endif diff --git a/src/gallium/drivers/radeon/r600d_common.h b/src/gallium/drivers/radeon/r600d_common.h index 3d86f70b162..fd9d79e63cb 100644 --- a/src/gallium/drivers/radeon/r600d_common.h +++ b/src/gallium/drivers/radeon/r600d_common.h @@ -33,9 +33,9 @@ #define CIK_UCONFIG_REG_OFFSET 0x00030000 #define CIK_UCONFIG_REG_END 0x00038000 -#define PKT_TYPE_S(x) (((x) & 0x3) << 30) -#define PKT_COUNT_S(x) (((x) & 0x3FFF) << 16) -#define PKT3_IT_OPCODE_S(x) (((x) & 0xFF) << 8) +#define PKT_TYPE_S(x) (((unsigned)(x) & 0x3) << 30) +#define PKT_COUNT_S(x) (((unsigned)(x) & 0x3FFF) << 16) +#define PKT3_IT_OPCODE_S(x) (((unsigned)(x) & 0xFF) << 8) #define PKT3_PREDICATE(x) (((x) >> 0) & 0x1) #define PKT3(op, count, predicate) (PKT_TYPE_S(3) | PKT_COUNT_S(count) | PKT3_IT_OPCODE_S(op) | PKT3_PREDICATE(predicate)) @@ -45,15 +45,15 @@ #define PKT3_SET_PREDICATION 0x20 #define PKT3_STRMOUT_BUFFER_UPDATE 0x34 #define STRMOUT_STORE_BUFFER_FILLED_SIZE 1 -#define STRMOUT_OFFSET_SOURCE(x) (((x) & 0x3) << 1) +#define STRMOUT_OFFSET_SOURCE(x) (((unsigned)(x) & 0x3) << 1) #define STRMOUT_OFFSET_FROM_PACKET 0 #define STRMOUT_OFFSET_FROM_VGT_FILLED_SIZE 1 #define STRMOUT_OFFSET_FROM_MEM 2 #define STRMOUT_OFFSET_NONE 3 -#define STRMOUT_SELECT_BUFFER(x) (((x) & 0x3) << 8) +#define STRMOUT_SELECT_BUFFER(x) (((unsigned)(x) & 0x3) << 8) #define PKT3_WAIT_REG_MEM 0x3C #define WAIT_REG_MEM_EQUAL 3 -#define WAIT_REG_MEM_MEM_SPACE(x) (((x) & 0x3) << 4) +#define WAIT_REG_MEM_MEM_SPACE(x) (((unsigned)(x) & 0x3) << 4) #define PKT3_EVENT_WRITE 0x46 #define PKT3_EVENT_WRITE_EOP 0x47 #define EOP_DATA_SEL(x) ((x) << 29) @@ -114,22 +114,22 @@ /* R600-R700*/ #define R_008490_CP_STRMOUT_CNTL 0x008490 -#define S_008490_OFFSET_UPDATE_DONE(x) (((x) & 0x1) << 0) +#define S_008490_OFFSET_UPDATE_DONE(x) (((unsigned)(x) & 0x1) << 0) #define R_028AB0_VGT_STRMOUT_EN 0x028AB0 -#define S_028AB0_STREAMOUT(x) (((x) & 0x1) << 0) +#define S_028AB0_STREAMOUT(x) (((unsigned)(x) & 0x1) << 0) #define G_028AB0_STREAMOUT(x) (((x) >> 0) & 0x1) #define C_028AB0_STREAMOUT 0xFFFFFFFE #define R_028B20_VGT_STRMOUT_BUFFER_EN 0x028B20 -#define S_028B20_BUFFER_0_EN(x) (((x) & 0x1) << 0) +#define S_028B20_BUFFER_0_EN(x) (((unsigned)(x) & 0x1) << 0) #define G_028B20_BUFFER_0_EN(x) (((x) >> 0) & 0x1) #define C_028B20_BUFFER_0_EN 0xFFFFFFFE -#define S_028B20_BUFFER_1_EN(x) (((x) & 0x1) << 1) +#define S_028B20_BUFFER_1_EN(x) (((unsigned)(x) & 0x1) << 1) #define G_028B20_BUFFER_1_EN(x) (((x) >> 1) & 0x1) #define C_028B20_BUFFER_1_EN 0xFFFFFFFD -#define S_028B20_BUFFER_2_EN(x) (((x) & 0x1) << 2) +#define S_028B20_BUFFER_2_EN(x) (((unsigned)(x) & 0x1) << 2) #define G_028B20_BUFFER_2_EN(x) (((x) >> 2) & 0x1) #define C_028B20_BUFFER_2_EN 0xFFFFFFFB -#define S_028B20_BUFFER_3_EN(x) (((x) & 0x1) << 3) +#define S_028B20_BUFFER_3_EN(x) (((unsigned)(x) & 0x1) << 3) #define G_028B20_BUFFER_3_EN(x) (((x) >> 3) & 0x1) #define C_028B20_BUFFER_3_EN 0xFFFFFFF7 #define R_028AD0_VGT_STRMOUT_BUFFER_SIZE_0 0x028AD0 @@ -141,82 +141,82 @@ /* EG+ */ #define R_0084FC_CP_STRMOUT_CNTL 0x0084FC -#define S_0084FC_OFFSET_UPDATE_DONE(x) (((x) & 0x1) << 0) +#define S_0084FC_OFFSET_UPDATE_DONE(x) (((unsigned)(x) & 0x1) << 0) #define R_028B94_VGT_STRMOUT_CONFIG 0x028B94 -#define S_028B94_STREAMOUT_0_EN(x) (((x) & 0x1) << 0) +#define S_028B94_STREAMOUT_0_EN(x) (((unsigned)(x) & 0x1) << 0) #define G_028B94_STREAMOUT_0_EN(x) (((x) >> 0) & 0x1) #define C_028B94_STREAMOUT_0_EN 0xFFFFFFFE -#define S_028B94_STREAMOUT_1_EN(x) (((x) & 0x1) << 1) +#define S_028B94_STREAMOUT_1_EN(x) (((unsigned)(x) & 0x1) << 1) #define G_028B94_STREAMOUT_1_EN(x) (((x) >> 1) & 0x1) #define C_028B94_STREAMOUT_1_EN 0xFFFFFFFD -#define S_028B94_STREAMOUT_2_EN(x) (((x) & 0x1) << 2) +#define S_028B94_STREAMOUT_2_EN(x) (((unsigned)(x) & 0x1) << 2) #define G_028B94_STREAMOUT_2_EN(x) (((x) >> 2) & 0x1) #define C_028B94_STREAMOUT_2_EN 0xFFFFFFFB -#define S_028B94_STREAMOUT_3_EN(x) (((x) & 0x1) << 3) +#define S_028B94_STREAMOUT_3_EN(x) (((unsigned)(x) & 0x1) << 3) #define G_028B94_STREAMOUT_3_EN(x) (((x) >> 3) & 0x1) #define C_028B94_STREAMOUT_3_EN 0xFFFFFFF7 -#define S_028B94_RAST_STREAM(x) (((x) & 0x07) << 4) +#define S_028B94_RAST_STREAM(x) (((unsigned)(x) & 0x07) << 4) #define G_028B94_RAST_STREAM(x) (((x) >> 4) & 0x07) #define C_028B94_RAST_STREAM 0xFFFFFF8F -#define S_028B94_RAST_STREAM_MASK(x) (((x) & 0x0F) << 8) /* SI+ */ +#define S_028B94_RAST_STREAM_MASK(x) (((unsigned)(x) & 0x0F) << 8) /* SI+ */ #define G_028B94_RAST_STREAM_MASK(x) (((x) >> 8) & 0x0F) #define C_028B94_RAST_STREAM_MASK 0xFFFFF0FF -#define S_028B94_USE_RAST_STREAM_MASK(x) (((x) & 0x1) << 31) /* SI+ */ +#define S_028B94_USE_RAST_STREAM_MASK(x) (((unsigned)(x) & 0x1) << 31) /* SI+ */ #define G_028B94_USE_RAST_STREAM_MASK(x) (((x) >> 31) & 0x1) #define C_028B94_USE_RAST_STREAM_MASK 0x7FFFFFFF #define R_028B98_VGT_STRMOUT_BUFFER_CONFIG 0x028B98 -#define S_028B98_STREAM_0_BUFFER_EN(x) (((x) & 0x0F) << 0) +#define S_028B98_STREAM_0_BUFFER_EN(x) (((unsigned)(x) & 0x0F) << 0) #define G_028B98_STREAM_0_BUFFER_EN(x) (((x) >> 0) & 0x0F) #define C_028B98_STREAM_0_BUFFER_EN 0xFFFFFFF0 -#define S_028B98_STREAM_1_BUFFER_EN(x) (((x) & 0x0F) << 4) +#define S_028B98_STREAM_1_BUFFER_EN(x) (((unsigned)(x) & 0x0F) << 4) #define G_028B98_STREAM_1_BUFFER_EN(x) (((x) >> 4) & 0x0F) #define C_028B98_STREAM_1_BUFFER_EN 0xFFFFFF0F -#define S_028B98_STREAM_2_BUFFER_EN(x) (((x) & 0x0F) << 8) +#define S_028B98_STREAM_2_BUFFER_EN(x) (((unsigned)(x) & 0x0F) << 8) #define G_028B98_STREAM_2_BUFFER_EN(x) (((x) >> 8) & 0x0F) #define C_028B98_STREAM_2_BUFFER_EN 0xFFFFF0FF -#define S_028B98_STREAM_3_BUFFER_EN(x) (((x) & 0x0F) << 12) +#define S_028B98_STREAM_3_BUFFER_EN(x) (((unsigned)(x) & 0x0F) << 12) #define G_028B98_STREAM_3_BUFFER_EN(x) (((x) >> 12) & 0x0F) #define C_028B98_STREAM_3_BUFFER_EN 0xFFFF0FFF #define EG_R_028A4C_PA_SC_MODE_CNTL_1 0x028A4C -#define EG_S_028A4C_PS_ITER_SAMPLE(x) (((x) & 0x1) << 16) -#define EG_S_028A4C_FORCE_EOV_CNTDWN_ENABLE(x) (((x) & 0x1) << 25) -#define EG_S_028A4C_FORCE_EOV_REZ_ENABLE(x) (((x) & 0x1) << 26) +#define EG_S_028A4C_PS_ITER_SAMPLE(x) (((unsigned)(x) & 0x1) << 16) +#define EG_S_028A4C_FORCE_EOV_CNTDWN_ENABLE(x) (((unsigned)(x) & 0x1) << 25) +#define EG_S_028A4C_FORCE_EOV_REZ_ENABLE(x) (((unsigned)(x) & 0x1) << 26) #define CM_R_028804_DB_EQAA 0x00028804 -#define S_028804_MAX_ANCHOR_SAMPLES(x) (((x) & 0x7) << 0) -#define S_028804_PS_ITER_SAMPLES(x) (((x) & 0x7) << 4) -#define S_028804_MASK_EXPORT_NUM_SAMPLES(x) (((x) & 0x7) << 8) -#define S_028804_ALPHA_TO_MASK_NUM_SAMPLES(x) (((x) & 0x7) << 12) -#define S_028804_HIGH_QUALITY_INTERSECTIONS(x) (((x) & 0x1) << 16) -#define S_028804_INCOHERENT_EQAA_READS(x) (((x) & 0x1) << 17) -#define S_028804_INTERPOLATE_COMP_Z(x) (((x) & 0x1) << 18) -#define S_028804_INTERPOLATE_SRC_Z(x) (((x) & 0x1) << 19) -#define S_028804_STATIC_ANCHOR_ASSOCIATIONS(x) (((x) & 0x1) << 20) -#define S_028804_ALPHA_TO_MASK_EQAA_DISABLE(x) (((x) & 0x1) << 21) -#define S_028804_OVERRASTERIZATION_AMOUNT(x) (((x) & 0x07) << 24) -#define S_028804_ENABLE_POSTZ_OVERRASTERIZATION(x) (((x) & 0x1) << 27) +#define S_028804_MAX_ANCHOR_SAMPLES(x) (((unsigned)(x) & 0x7) << 0) +#define S_028804_PS_ITER_SAMPLES(x) (((unsigned)(x) & 0x7) << 4) +#define S_028804_MASK_EXPORT_NUM_SAMPLES(x) (((unsigned)(x) & 0x7) << 8) +#define S_028804_ALPHA_TO_MASK_NUM_SAMPLES(x) (((unsigned)(x) & 0x7) << 12) +#define S_028804_HIGH_QUALITY_INTERSECTIONS(x) (((unsigned)(x) & 0x1) << 16) +#define S_028804_INCOHERENT_EQAA_READS(x) (((unsigned)(x) & 0x1) << 17) +#define S_028804_INTERPOLATE_COMP_Z(x) (((unsigned)(x) & 0x1) << 18) +#define S_028804_INTERPOLATE_SRC_Z(x) (((unsigned)(x) & 0x1) << 19) +#define S_028804_STATIC_ANCHOR_ASSOCIATIONS(x) (((unsigned)(x) & 0x1) << 20) +#define S_028804_ALPHA_TO_MASK_EQAA_DISABLE(x) (((unsigned)(x) & 0x1) << 21) +#define S_028804_OVERRASTERIZATION_AMOUNT(x) (((unsigned)(x) & 0x07) << 24) +#define S_028804_ENABLE_POSTZ_OVERRASTERIZATION(x) (((unsigned)(x) & 0x1) << 27) #define CM_R_028BDC_PA_SC_LINE_CNTL 0x28bdc -#define S_028BDC_EXPAND_LINE_WIDTH(x) (((x) & 0x1) << 9) +#define S_028BDC_EXPAND_LINE_WIDTH(x) (((unsigned)(x) & 0x1) << 9) #define G_028BDC_EXPAND_LINE_WIDTH(x) (((x) >> 9) & 0x1) #define C_028BDC_EXPAND_LINE_WIDTH 0xFFFFFDFF -#define S_028BDC_LAST_PIXEL(x) (((x) & 0x1) << 10) +#define S_028BDC_LAST_PIXEL(x) (((unsigned)(x) & 0x1) << 10) #define G_028BDC_LAST_PIXEL(x) (((x) >> 10) & 0x1) #define C_028BDC_LAST_PIXEL 0xFFFFFBFF #define CM_R_028BE0_PA_SC_AA_CONFIG 0x28be0 -#define S_028BE0_MSAA_NUM_SAMPLES(x) (((x) & 0x7) << 0) -#define S_028BE0_AA_MASK_CENTROID_DTMN(x) (((x) & 0x1) << 4) -#define S_028BE0_MAX_SAMPLE_DIST(x) (((x) & 0xf) << 13) -#define S_028BE0_MSAA_EXPOSED_SAMPLES(x) (((x) & 0x7) << 20) -#define S_028BE0_DETAIL_TO_EXPOSED_MODE(x) (((x) & 0x3) << 24) +#define S_028BE0_MSAA_NUM_SAMPLES(x) (((unsigned)(x) & 0x7) << 0) +#define S_028BE0_AA_MASK_CENTROID_DTMN(x) (((unsigned)(x) & 0x1) << 4) +#define S_028BE0_MAX_SAMPLE_DIST(x) (((unsigned)(x) & 0xf) << 13) +#define S_028BE0_MSAA_EXPOSED_SAMPLES(x) (((unsigned)(x) & 0x7) << 20) +#define S_028BE0_DETAIL_TO_EXPOSED_MODE(x) (((unsigned)(x) & 0x3) << 24) #define CM_R_028BF8_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y0_0 0x28bf8 #define CM_R_028C08_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y0_0 0x28c08 #define CM_R_028C18_PA_SC_AA_SAMPLE_LOCS_PIXEL_X0Y1_0 0x28c18 #define CM_R_028C28_PA_SC_AA_SAMPLE_LOCS_PIXEL_X1Y1_0 0x28c28 -#define EG_S_028C70_FAST_CLEAR(x) (((x) & 0x1) << 17) -#define SI_S_028C70_FAST_CLEAR(x) (((x) & 0x1) << 13) -#define VI_S_028C70_DCC_ENABLE(x) (((x) & 0x1) << 28) +#define EG_S_028C70_FAST_CLEAR(x) (((unsigned)(x) & 0x1) << 17) +#define SI_S_028C70_FAST_CLEAR(x) (((unsigned)(x) & 0x1) << 13) +#define VI_S_028C70_DCC_ENABLE(x) (((unsigned)(x) & 0x1) << 28) /*CIK+*/ #define R_0300FC_CP_STRMOUT_CNTL 0x0300FC @@ -226,19 +226,19 @@ #define R_02843C_PA_CL_VPORT_XSCALE 0x02843C #define R_028250_PA_SC_VPORT_SCISSOR_0_TL 0x028250 -#define S_028250_TL_X(x) (((x) & 0x7FFF) << 0) +#define S_028250_TL_X(x) (((unsigned)(x) & 0x7FFF) << 0) #define G_028250_TL_X(x) (((x) >> 0) & 0x7FFF) #define C_028250_TL_X 0xFFFF8000 -#define S_028250_TL_Y(x) (((x) & 0x7FFF) << 16) +#define S_028250_TL_Y(x) (((unsigned)(x) & 0x7FFF) << 16) #define G_028250_TL_Y(x) (((x) >> 16) & 0x7FFF) #define C_028250_TL_Y 0x8000FFFF -#define S_028250_WINDOW_OFFSET_DISABLE(x) (((x) & 0x1) << 31) +#define S_028250_WINDOW_OFFSET_DISABLE(x) (((unsigned)(x) & 0x1) << 31) #define G_028250_WINDOW_OFFSET_DISABLE(x) (((x) >> 31) & 0x1) #define C_028250_WINDOW_OFFSET_DISABLE 0x7FFFFFFF -#define S_028254_BR_X(x) (((x) & 0x7FFF) << 0) +#define S_028254_BR_X(x) (((unsigned)(x) & 0x7FFF) << 0) #define G_028254_BR_X(x) (((x) >> 0) & 0x7FFF) #define C_028254_BR_X 0xFFFF8000 -#define S_028254_BR_Y(x) (((x) & 0x7FFF) << 16) +#define S_028254_BR_Y(x) (((unsigned)(x) & 0x7FFF) << 16) #define G_028254_BR_Y(x) (((x) >> 16) & 0x7FFF) #define C_028254_BR_Y 0x8000FFFF diff --git a/src/gallium/drivers/radeon/radeon_uvd.h b/src/gallium/drivers/radeon/radeon_uvd.h index 30738bf0e82..bb1782ab749 100644 --- a/src/gallium/drivers/radeon/radeon_uvd.h +++ b/src/gallium/drivers/radeon/radeon_uvd.h @@ -38,13 +38,13 @@ #include "vl/vl_video_buffer.h" /* UVD uses PM4 packet type 0 and 2 */ -#define RUVD_PKT_TYPE_S(x) (((x) & 0x3) << 30) +#define RUVD_PKT_TYPE_S(x) (((unsigned)(x) & 0x3) << 30) #define RUVD_PKT_TYPE_G(x) (((x) >> 30) & 0x3) #define RUVD_PKT_TYPE_C 0x3FFFFFFF -#define RUVD_PKT_COUNT_S(x) (((x) & 0x3FFF) << 16) +#define RUVD_PKT_COUNT_S(x) (((unsigned)(x) & 0x3FFF) << 16) #define RUVD_PKT_COUNT_G(x) (((x) >> 16) & 0x3FFF) #define RUVD_PKT_COUNT_C 0xC000FFFF -#define RUVD_PKT0_BASE_INDEX_S(x) (((x) & 0xFFFF) << 0) +#define RUVD_PKT0_BASE_INDEX_S(x) (((unsigned)(x) & 0xFFFF) << 0) #define RUVD_PKT0_BASE_INDEX_G(x) (((x) >> 0) & 0xFFFF) #define RUVD_PKT0_BASE_INDEX_C 0xFFFF0000 #define RUVD_PKT0(index, count) (RUVD_PKT_TYPE_S(0) | RUVD_PKT0_BASE_INDEX_S(index) | RUVD_PKT_COUNT_S(count)) |