-if (SHAMT >= xlen)
- throw trap_illegal_instruction();
+require(SHAMT < xlen);
WRITE_RD(sext_xlen(RS1 << SHAMT));
-if (xlen == 64)
- WRITE_RD(sreg_t(RS1) >> SHAMT);
-else
-{
- if(SHAMT & 0x20)
- throw trap_illegal_instruction();
- WRITE_RD(sext32(int32_t(RS1) >> SHAMT));
-}
+require(SHAMT < xlen);
+WRITE_RD(sext_xlen(sext_xlen(RS1) >> SHAMT));
-if (xlen == 64)
- WRITE_RD(RS1 >> (RS2 & 0x3F));
-else
- WRITE_RD(sext32((uint32_t)RS1 >> (RS2 & 0x1F)));
+WRITE_RD(sext_xlen(zext_xlen(RS1) >> (RS2 & (xlen-1))));
-if (xlen == 64)
- WRITE_RD(RS1 >> SHAMT);
-else
-{
- if(SHAMT & 0x20)
- throw trap_illegal_instruction();
- WRITE_RD(sext32((uint32_t)RS1 >> SHAMT));
-}
+require(SHAMT < xlen);
+WRITE_RD(sext_xlen(zext_xlen(RS1) >> SHAMT));