Skip to content

Commit a25aa2b

Browse files
committed
py/asmxtensa.h: Explicitly cast args to 32-bits so left-shift is legal.
For archs that have 16-bit pointers, the asmxtensa.h file can give compiler warnings about left-shift being greater than the width of the type (due to the inline functions in this header file). Explicitly casting the constants to uint32_t stops these warnings.
1 parent 21f0852 commit a25aa2b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

py/asmxtensa.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,19 @@
7373

7474
// macros for encoding instructions (little endian versions)
7575
#define ASM_XTENSA_ENCODE_RRR(op0, op1, op2, r, s, t) \
76-
(((op2) << 20) | ((op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0))
76+
((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0))
7777
#define ASM_XTENSA_ENCODE_RRI4(op0, op1, r, s, t, imm4) \
7878
(((imm4) << 20) | ((op1) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0))
7979
#define ASM_XTENSA_ENCODE_RRI8(op0, r, s, t, imm8) \
80-
(((imm8) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0))
80+
((((uint32_t)imm8) << 16) | ((r) << 12) | ((s) << 8) | ((t) << 4) | (op0))
8181
#define ASM_XTENSA_ENCODE_RI16(op0, t, imm16) \
8282
(((imm16) << 8) | ((t) << 4) | (op0))
8383
#define ASM_XTENSA_ENCODE_RSR(op0, op1, op2, rs, t) \
8484
(((op2) << 20) | ((op1) << 16) | ((rs) << 8) | ((t) << 4) | (op0))
8585
#define ASM_XTENSA_ENCODE_CALL(op0, n, offset) \
8686
(((offset) << 6) | ((n) << 4) | (op0))
8787
#define ASM_XTENSA_ENCODE_CALLX(op0, op1, op2, r, s, m, n) \
88-
(((op2) << 20) | ((op1) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0))
88+
((((uint32_t)op2) << 20) | (((uint32_t)op1) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0))
8989
#define ASM_XTENSA_ENCODE_BRI8(op0, r, s, m, n, imm8) \
9090
(((imm8) << 16) | ((r) << 12) | ((s) << 8) | ((m) << 6) | ((n) << 4) | (op0))
9191
#define ASM_XTENSA_ENCODE_BRI12(op0, s, m, n, imm12) \

0 commit comments

Comments
 (0)