@@ -850,11 +850,15 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
850
850
rdValue = shr64 (and64 (imm , byteToU64 (0x3F )), rs1Value ) // lower 6 bits in 64 bit mode
851
851
case 0x10 : // 010000 = SRAI
852
852
rdValue = sar64 (and64 (imm , byteToU64 (0x3F )), rs1Value ) // lower 6 bits in 64 bit mode
853
+ default :
854
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid imm value %d for opcode 0x13" , imm .val ()))
853
855
}
854
856
case 6 : // 110 = ORI
855
857
rdValue = or64 (rs1Value , imm )
856
858
case 7 : // 111 = ANDI
857
859
rdValue = and64 (rs1Value , imm )
860
+ default :
861
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct3 value %d for opcode 0x13" , funct3 .val ()))
858
862
}
859
863
setRegister (rd , rdValue )
860
864
setPC (add64 (pc , byteToU64 (4 )))
@@ -882,7 +886,11 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
882
886
rdValue = signExtend64 (shr64 (shamt , and64 (rs1Value , u32Mask ())), byteToU64 (31 ))
883
887
case 0x20 : // 0100000 = SRAIW
884
888
rdValue = signExtend64 (shr64 (shamt , and64 (rs1Value , u32Mask ())), sub64 (byteToU64 (31 ), shamt ))
889
+ default :
890
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid imm value %d for opcode 0x1B" , imm .val ()))
885
891
}
892
+ default :
893
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct3 value %d for opcode 0x1B" , funct3 .val ()))
886
894
}
887
895
setRegister (rd , rdValue )
888
896
setPC (add64 (pc , byteToU64 (4 )))
@@ -929,6 +937,8 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
929
937
default :
930
938
rdValue = mod64 (rs1Value , rs2Value )
931
939
}
940
+ default :
941
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct3 value %d for opcode 0x33" , funct3 .val ()))
932
942
}
933
943
default :
934
944
switch funct3 .val () {
@@ -938,6 +948,8 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
938
948
rdValue = add64 (rs1Value , rs2Value )
939
949
case 0x20 : // 0100000 = SUB
940
950
rdValue = sub64 (rs1Value , rs2Value )
951
+ default :
952
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct7 value %d for funct3 %d" , funct7 .val (), funct3 .val ()))
941
953
}
942
954
case 1 : // 001 = SLL
943
955
rdValue = shl64 (and64 (rs2Value , byteToU64 (0x3F )), rs1Value ) // only the low 6 bits are consider in RV6VI
@@ -953,11 +965,15 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
953
965
rdValue = shr64 (and64 (rs2Value , byteToU64 (0x3F )), rs1Value ) // logical: fill with zeroes
954
966
case 0x20 : // 0100000 = SRA
955
967
rdValue = sar64 (and64 (rs2Value , byteToU64 (0x3F )), rs1Value ) // arithmetic: sign bit is extended
968
+ default :
969
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct7 value %d for funct3 %d" , funct7 .val (), funct3 .val ()))
956
970
}
957
971
case 6 : // 110 = OR
958
972
rdValue = or64 (rs1Value , rs2Value )
959
973
case 7 : // 111 = AND
960
974
rdValue = and64 (rs1Value , rs2Value )
975
+ default :
976
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct3 value %d for opcode 0x3B" , funct3 .val ()))
961
977
}
962
978
}
963
979
setRegister (rd , rdValue )
@@ -999,6 +1015,8 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
999
1015
default :
1000
1016
rdValue = mask32Signed64 (mod64 (and64 (rs1Value , u32Mask ()), and64 (rs2Value , u32Mask ())))
1001
1017
}
1018
+ default :
1019
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct3 value %d for opcode 0x3B" , funct3 .val ()))
1002
1020
}
1003
1021
default :
1004
1022
switch funct3 .val () {
@@ -1008,6 +1026,8 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
1008
1026
rdValue = mask32Signed64 (add64 (and64 (rs1Value , u32Mask ()), and64 (rs2Value , u32Mask ())))
1009
1027
case 0x20 : // 0100000 = SUBW
1010
1028
rdValue = mask32Signed64 (sub64 (and64 (rs1Value , u32Mask ()), and64 (rs2Value , u32Mask ())))
1029
+ default :
1030
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct7 value %d for funct3 %d" , funct7 .val (), funct3 .val ()))
1011
1031
}
1012
1032
case 1 : // 001 = SLLW
1013
1033
rdValue = mask32Signed64 (shl64 (and64 (rs2Value , byteToU64 (0x1F )), rs1Value ))
@@ -1018,7 +1038,11 @@ func Step(calldata []byte, po PreimageOracle) (stateHash common.Hash, outErr err
1018
1038
rdValue = signExtend64 (shr64 (shamt , and64 (rs1Value , u32Mask ())), byteToU64 (31 ))
1019
1039
case 0x20 : // 0100000 = SRAW
1020
1040
rdValue = signExtend64 (shr64 (shamt , and64 (rs1Value , u32Mask ())), sub64 (byteToU64 (31 ), shamt ))
1041
+ default :
1042
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct7 value %d for funct3 %d" , funct7 .val (), funct3 .val ()))
1021
1043
}
1044
+ default :
1045
+ revertWithCode (riscv .ErrIllegalInstruction , fmt .Errorf ("illegal instruction: invalid funct3 value %d for opcode 0x3B" , funct3 .val ()))
1022
1046
}
1023
1047
}
1024
1048
setRegister (rd , rdValue )
0 commit comments