#[repr(u32)]pub enum Opcode {
Show 1040 variants
ADD = 0,
ADDUW = 1,
ADDI = 2,
ADDIW = 3,
ADDW = 4,
AES32DSI = 5,
AES32DSMI = 6,
AES32ESI = 7,
AES32ESMI = 8,
AES64DS = 9,
AES64DSM = 10,
AES64ES = 11,
AES64ESM = 12,
AES64IM = 13,
AES64KS1I = 14,
AES64KS2 = 15,
AMOADDB = 16,
AMOADDD = 17,
AMOADDH = 18,
AMOADDW = 19,
AMOANDB = 20,
AMOANDD = 21,
AMOANDH = 22,
AMOANDW = 23,
AMOCASB = 24,
AMOCASD = 25,
AMOCASH = 26,
AMOCASQ = 27,
AMOCASW = 28,
AMOMAXB = 29,
AMOMAXD = 30,
AMOMAXH = 31,
AMOMAXW = 32,
AMOMAXUB = 33,
AMOMAXUD = 34,
AMOMAXUH = 35,
AMOMAXUW = 36,
AMOMINB = 37,
AMOMIND = 38,
AMOMINH = 39,
AMOMINW = 40,
AMOMINUB = 41,
AMOMINUD = 42,
AMOMINUH = 43,
AMOMINUW = 44,
AMOORB = 45,
AMOORD = 46,
AMOORH = 47,
AMOORW = 48,
AMOSWAPB = 49,
AMOSWAPD = 50,
AMOSWAPH = 51,
AMOSWAPW = 52,
AMOXORB = 53,
AMOXORD = 54,
AMOXORH = 55,
AMOXORW = 56,
AND = 57,
ANDI = 58,
ANDN = 59,
AUIPC = 60,
BCLR = 61,
BCLRI = 62,
BCLRIRV32 = 63,
BEQ = 64,
BEQZ = 65,
BEXT = 66,
BEXTI = 67,
BEXTIRV32 = 68,
BGE = 69,
BGEU = 70,
BGEZ = 71,
BGT = 72,
BGTU = 73,
BGTZ = 74,
BINV = 75,
BINVI = 76,
BINVIRV32 = 77,
BLE = 78,
BLEU = 79,
BLEZ = 80,
BLT = 81,
BLTU = 82,
BLTZ = 83,
BNE = 84,
BNEZ = 85,
BREV8 = 86,
BSET = 87,
BSETI = 88,
BSETIRV32 = 89,
CADD = 90,
CADDI = 91,
CADDI16SP = 92,
CADDI4SPN = 93,
CADDIW = 94,
CADDW = 95,
CAND = 96,
CANDI = 97,
CBEQZ = 98,
CBNEZ = 99,
CEBREAK = 100,
CFLD = 101,
CFLDSP = 102,
CFLW = 103,
CFLWSP = 104,
CFSD = 105,
CFSDSP = 106,
CFSW = 107,
CFSWSP = 108,
CJ = 109,
CJAL = 110,
CJALR = 111,
CJR = 112,
CLBU = 113,
CLD = 114,
CLDSP = 115,
CLH = 116,
CLHU = 117,
CLI = 118,
CLUI = 119,
CLW = 120,
CLWSP = 121,
CMOP1 = 122,
CMOP11 = 123,
CMOP13 = 124,
CMOP15 = 125,
CMOP3 = 126,
CMOP5 = 127,
CMOP7 = 128,
CMOP9 = 129,
CMOPN = 130,
CMUL = 131,
CMV = 132,
CNOP = 133,
CNOT = 134,
CNTLALL = 135,
CNTLP1 = 136,
CNTLPALL = 137,
CNTLS1 = 138,
COR = 139,
CSB = 140,
CSD = 141,
CSDSP = 142,
CSEXTB = 143,
CSEXTH = 144,
CSEXTW = 145,
CSH = 146,
CSLLI = 147,
CSLLIRV32 = 148,
CSRAI = 149,
CSRAIRV32 = 150,
CSRLI = 151,
CSRLIRV32 = 152,
CSSPOPCHKX5 = 153,
CSSPUSHX1 = 154,
CSUB = 155,
CSUBW = 156,
CSW = 157,
CSWSP = 158,
CXOR = 159,
CZEXTB = 160,
CZEXTH = 161,
CZEXTW = 162,
CBOCLEAN = 163,
CBOFLUSH = 164,
CBOINVAL = 165,
CBOZERO = 166,
CLMUL = 167,
CLMULH = 168,
CLMULR = 169,
CLZ = 170,
CLZW = 171,
CMJALT = 172,
CMMVA01S = 173,
CMMVSA01 = 174,
CMPOP = 175,
CMPOPRET = 176,
CMPOPRETZ = 177,
CMPUSH = 178,
CPOP = 179,
CPOPW = 180,
CSRC = 181,
CSRCI = 182,
CSRR = 183,
CSRRC = 184,
CSRRCI = 185,
CSRRS = 186,
CSRRSI = 187,
CSRRW = 188,
CSRRWI = 189,
CSRS = 190,
CSRSI = 191,
CSRW = 192,
CSRWI = 193,
CTZ = 194,
CTZW = 195,
CZEROEQZ = 196,
CZERONEZ = 197,
DIV = 198,
DIVU = 199,
DIVUW = 200,
DIVW = 201,
DRET = 202,
EBREAK = 203,
ECALL = 204,
FABSD = 205,
FABSH = 206,
FABSQ = 207,
FABSS = 208,
FADDD = 209,
FADDH = 210,
FADDQ = 211,
FADDS = 212,
FCLASSD = 213,
FCLASSH = 214,
FCLASSQ = 215,
FCLASSS = 216,
FCVTBF16S = 217,
FCVTDH = 218,
FCVTDL = 219,
FCVTDLU = 220,
FCVTDQ = 221,
FCVTDS = 222,
FCVTDW = 223,
FCVTDWU = 224,
FCVTHD = 225,
FCVTHL = 226,
FCVTHLU = 227,
FCVTHQ = 228,
FCVTHS = 229,
FCVTHW = 230,
FCVTHWU = 231,
FCVTLD = 232,
FCVTLH = 233,
FCVTLQ = 234,
FCVTLS = 235,
FCVTLUD = 236,
FCVTLUH = 237,
FCVTLUQ = 238,
FCVTLUS = 239,
FCVTQD = 240,
FCVTQH = 241,
FCVTQL = 242,
FCVTQLU = 243,
FCVTQS = 244,
FCVTQW = 245,
FCVTQWU = 246,
FCVTSBF16 = 247,
FCVTSD = 248,
FCVTSH = 249,
FCVTSL = 250,
FCVTSLU = 251,
FCVTSQ = 252,
FCVTSW = 253,
FCVTSWU = 254,
FCVTWD = 255,
FCVTWH = 256,
FCVTWQ = 257,
FCVTWS = 258,
FCVTWUD = 259,
FCVTWUH = 260,
FCVTWUQ = 261,
FCVTWUS = 262,
FCVTMODWD = 263,
FDIVD = 264,
FDIVH = 265,
FDIVQ = 266,
FDIVS = 267,
FENCE = 268,
FENCEI = 269,
FENCETSO = 270,
FEQD = 271,
FEQH = 272,
FEQQ = 273,
FEQS = 274,
FLD = 275,
FLED = 276,
FLEH = 277,
FLEQ = 278,
FLES = 279,
FLEQD = 280,
FLEQH = 281,
FLEQQ = 282,
FLEQS = 283,
FLH = 284,
FLID = 285,
FLIH = 286,
FLIQ = 287,
FLIS = 288,
FLQ = 289,
FLTD = 290,
FLTH = 291,
FLTQ = 292,
FLTS = 293,
FLTQD = 294,
FLTQH = 295,
FLTQQ = 296,
FLTQS = 297,
FLW = 298,
FMADDD = 299,
FMADDH = 300,
FMADDQ = 301,
FMADDS = 302,
FMAXD = 303,
FMAXH = 304,
FMAXQ = 305,
FMAXS = 306,
FMAXMD = 307,
FMAXMH = 308,
FMAXMQ = 309,
FMAXMS = 310,
FMIND = 311,
FMINH = 312,
FMINQ = 313,
FMINS = 314,
FMINMD = 315,
FMINMH = 316,
FMINMQ = 317,
FMINMS = 318,
FMSUBD = 319,
FMSUBH = 320,
FMSUBQ = 321,
FMSUBS = 322,
FMULD = 323,
FMULH = 324,
FMULQ = 325,
FMULS = 326,
FMVD = 327,
FMVDX = 328,
FMVH = 329,
FMVHX = 330,
FMVQ = 331,
FMVS = 332,
FMVSX = 333,
FMVWX = 334,
FMVXD = 335,
FMVXH = 336,
FMVXS = 337,
FMVXW = 338,
FMVHXD = 339,
FMVHXQ = 340,
FMVPDX = 341,
FMVPQX = 342,
FNEGD = 343,
FNEGH = 344,
FNEGQ = 345,
FNEGS = 346,
FNMADDD = 347,
FNMADDH = 348,
FNMADDQ = 349,
FNMADDS = 350,
FNMSUBD = 351,
FNMSUBH = 352,
FNMSUBQ = 353,
FNMSUBS = 354,
FRCSR = 355,
FRFLAGS = 356,
FROUNDD = 357,
FROUNDH = 358,
FROUNDQ = 359,
FROUNDS = 360,
FROUNDNXD = 361,
FROUNDNXH = 362,
FROUNDNXQ = 363,
FROUNDNXS = 364,
FRRM = 365,
FSCSR = 366,
FSD = 367,
FSFLAGS = 368,
FSFLAGSI = 369,
FSGNJD = 370,
FSGNJH = 371,
FSGNJQ = 372,
FSGNJS = 373,
FSGNJND = 374,
FSGNJNH = 375,
FSGNJNQ = 376,
FSGNJNS = 377,
FSGNJXD = 378,
FSGNJXH = 379,
FSGNJXQ = 380,
FSGNJXS = 381,
FSH = 382,
FSQ = 383,
FSQRTD = 384,
FSQRTH = 385,
FSQRTQ = 386,
FSQRTS = 387,
FSRM = 388,
FSRMI = 389,
FSUBD = 390,
FSUBH = 391,
FSUBQ = 392,
FSUBS = 393,
FSW = 394,
HFENCEGVMA = 395,
HFENCEVVMA = 396,
HINVALGVMA = 397,
HINVALVVMA = 398,
HLVB = 399,
HLVBU = 400,
HLVD = 401,
HLVH = 402,
HLVHU = 403,
HLVW = 404,
HLVWU = 405,
HLVXHU = 406,
HLVXWU = 407,
HSVB = 408,
HSVD = 409,
HSVH = 410,
HSVW = 411,
J = 412,
JAL = 413,
JALPSEUDO = 414,
JALR = 415,
JALRPSEUDO = 416,
JR = 417,
LB = 418,
LBU = 419,
LD = 420,
LH = 421,
LHU = 422,
LPAD = 423,
LRD = 424,
LRW = 425,
LUI = 426,
LW = 427,
LWU = 428,
MAX = 429,
MAXU = 430,
MIN = 431,
MINU = 432,
MNRET = 433,
MOPR0 = 434,
MOPR1 = 435,
MOPR10 = 436,
MOPR11 = 437,
MOPR12 = 438,
MOPR13 = 439,
MOPR14 = 440,
MOPR15 = 441,
MOPR16 = 442,
MOPR17 = 443,
MOPR18 = 444,
MOPR19 = 445,
MOPR2 = 446,
MOPR20 = 447,
MOPR21 = 448,
MOPR22 = 449,
MOPR23 = 450,
MOPR24 = 451,
MOPR25 = 452,
MOPR26 = 453,
MOPR27 = 454,
MOPR28 = 455,
MOPR29 = 456,
MOPR3 = 457,
MOPR30 = 458,
MOPR31 = 459,
MOPR4 = 460,
MOPR5 = 461,
MOPR6 = 462,
MOPR7 = 463,
MOPR8 = 464,
MOPR9 = 465,
MOPRN = 466,
MOPRR0 = 467,
MOPRR1 = 468,
MOPRR2 = 469,
MOPRR3 = 470,
MOPRR4 = 471,
MOPRR5 = 472,
MOPRR6 = 473,
MOPRR7 = 474,
MOPRRN = 475,
MRET = 476,
MUL = 477,
MULH = 478,
MULHSU = 479,
MULHU = 480,
MULW = 481,
MV = 482,
NEG = 483,
NOP = 484,
NTLALL = 485,
NTLP1 = 486,
NTLPALL = 487,
NTLS1 = 488,
OR = 489,
ORCB = 490,
ORI = 491,
ORN = 492,
PACK = 493,
PACKH = 494,
PACKW = 495,
PAUSE = 496,
PREFETCHI = 497,
PREFETCHR = 498,
PREFETCHW = 499,
RDCYCLE = 500,
RDCYCLEH = 501,
RDINSTRET = 502,
RDINSTRETH = 503,
RDTIME = 504,
RDTIMEH = 505,
REM = 506,
REMU = 507,
REMUW = 508,
REMW = 509,
RET = 510,
REV8 = 511,
REV8RV32 = 512,
ROL = 513,
ROLW = 514,
ROR = 515,
RORI = 516,
RORIRV32 = 517,
RORIW = 518,
RORW = 519,
SB = 520,
SBREAK = 521,
SCD = 522,
SCW = 523,
SCALL = 524,
SCTRCLR = 525,
SD = 526,
SEQZ = 527,
SEXTB = 528,
SEXTH = 529,
SEXTW = 530,
SFENCEINVALIR = 531,
SFENCEVMA = 532,
SFENCEWINVAL = 533,
SGTZ = 534,
SH = 535,
SH1ADD = 536,
SH1ADDUW = 537,
SH2ADD = 538,
SH2ADDUW = 539,
SH3ADD = 540,
SH3ADDUW = 541,
SHA256SIG0 = 542,
SHA256SIG1 = 543,
SHA256SUM0 = 544,
SHA256SUM1 = 545,
SHA512SIG0 = 546,
SHA512SIG0H = 547,
SHA512SIG0L = 548,
SHA512SIG1 = 549,
SHA512SIG1H = 550,
SHA512SIG1L = 551,
SHA512SUM0 = 552,
SHA512SUM0R = 553,
SHA512SUM1 = 554,
SHA512SUM1R = 555,
SINVALVMA = 556,
SLL = 557,
SLLI = 558,
SLLIRV32 = 559,
SLLIUW = 560,
SLLIW = 561,
SLLW = 562,
SLT = 563,
SLTI = 564,
SLTIU = 565,
SLTU = 566,
SLTZ = 567,
SM3P0 = 568,
SM3P1 = 569,
SM4ED = 570,
SM4KS = 571,
SNEZ = 572,
SRA = 573,
SRAI = 574,
SRAIRV32 = 575,
SRAIW = 576,
SRAW = 577,
SRET = 578,
SRL = 579,
SRLI = 580,
SRLIRV32 = 581,
SRLIW = 582,
SRLW = 583,
SSAMOSWAPD = 584,
SSAMOSWAPW = 585,
SSPOPCHKX1 = 586,
SSPOPCHKX5 = 587,
SSPUSHX1 = 588,
SSPUSHX5 = 589,
SSRDP = 590,
SUB = 591,
SUBW = 592,
SW = 593,
UNZIP = 594,
VAADDVV = 595,
VAADDVX = 596,
VAADDUVV = 597,
VAADDUVX = 598,
VADCVIM = 599,
VADCVVM = 600,
VADCVXM = 601,
VADDVI = 602,
VADDVV = 603,
VADDVX = 604,
VAESDFVS = 605,
VAESDFVV = 606,
VAESDMVS = 607,
VAESDMVV = 608,
VAESEFVS = 609,
VAESEFVV = 610,
VAESEMVS = 611,
VAESEMVV = 612,
VAESKF1VI = 613,
VAESKF2VI = 614,
VAESZVS = 615,
VANDVI = 616,
VANDVV = 617,
VANDVX = 618,
VANDNVV = 619,
VANDNVX = 620,
VASUBVV = 621,
VASUBVX = 622,
VASUBUVV = 623,
VASUBUVX = 624,
VBREV8V = 625,
VBREVV = 626,
VCLMULVV = 627,
VCLMULVX = 628,
VCLMULHVV = 629,
VCLMULHVX = 630,
VCLZV = 631,
VCOMPRESSVM = 632,
VCPOPM = 633,
VCPOPV = 634,
VCTZV = 635,
VDIVVV = 636,
VDIVVX = 637,
VDIVUVV = 638,
VDIVUVX = 639,
VFADDVF = 640,
VFADDVV = 641,
VFCLASSV = 642,
VFCVTFXV = 643,
VFCVTFXUV = 644,
VFCVTRTZXFV = 645,
VFCVTRTZXUFV = 646,
VFCVTXFV = 647,
VFCVTXUFV = 648,
VFDIVVF = 649,
VFDIVVV = 650,
VFIRSTM = 651,
VFMACCVF = 652,
VFMACCVV = 653,
VFMADDVF = 654,
VFMADDVV = 655,
VFMAXVF = 656,
VFMAXVV = 657,
VFMERGEVFM = 658,
VFMINVF = 659,
VFMINVV = 660,
VFMSACVF = 661,
VFMSACVV = 662,
VFMSUBVF = 663,
VFMSUBVV = 664,
VFMULVF = 665,
VFMULVV = 666,
VFMVFS = 667,
VFMVSF = 668,
VFMVVF = 669,
VFNCVTFFW = 670,
VFNCVTFXW = 671,
VFNCVTFXUW = 672,
VFNCVTRODFFW = 673,
VFNCVTRTZXFW = 674,
VFNCVTRTZXUFW = 675,
VFNCVTXFW = 676,
VFNCVTXUFW = 677,
VFNCVTBF16FFW = 678,
VFNMACCVF = 679,
VFNMACCVV = 680,
VFNMADDVF = 681,
VFNMADDVV = 682,
VFNMSACVF = 683,
VFNMSACVV = 684,
VFNMSUBVF = 685,
VFNMSUBVV = 686,
VFRDIVVF = 687,
VFREC7V = 688,
VFREDMAXVS = 689,
VFREDMINVS = 690,
VFREDOSUMVS = 691,
VFREDSUMVS = 692,
VFREDUSUMVS = 693,
VFRSQRT7V = 694,
VFRSUBVF = 695,
VFSGNJVF = 696,
VFSGNJVV = 697,
VFSGNJNVF = 698,
VFSGNJNVV = 699,
VFSGNJXVF = 700,
VFSGNJXVV = 701,
VFSLIDE1DOWNVF = 702,
VFSLIDE1UPVF = 703,
VFSQRTV = 704,
VFSUBVF = 705,
VFSUBVV = 706,
VFWADDVF = 707,
VFWADDVV = 708,
VFWADDWF = 709,
VFWADDWV = 710,
VFWCVTFFV = 711,
VFWCVTFXV = 712,
VFWCVTFXUV = 713,
VFWCVTRTZXFV = 714,
VFWCVTRTZXUFV = 715,
VFWCVTXFV = 716,
VFWCVTXUFV = 717,
VFWCVTBF16FFV = 718,
VFWMACCVF = 719,
VFWMACCVV = 720,
VFWMACCBF16VF = 721,
VFWMACCBF16VV = 722,
VFWMSACVF = 723,
VFWMSACVV = 724,
VFWMULVF = 725,
VFWMULVV = 726,
VFWNMACCVF = 727,
VFWNMACCVV = 728,
VFWNMSACVF = 729,
VFWNMSACVV = 730,
VFWREDOSUMVS = 731,
VFWREDSUMVS = 732,
VFWREDUSUMVS = 733,
VFWSUBVF = 734,
VFWSUBVV = 735,
VFWSUBWF = 736,
VFWSUBWV = 737,
VGHSHVV = 738,
VGMULVV = 739,
VIDV = 740,
VIOTAM = 741,
VL1RV = 742,
VL1RE16V = 743,
VL1RE32V = 744,
VL1RE64V = 745,
VL1RE8V = 746,
VL2RV = 747,
VL2RE16V = 748,
VL2RE32V = 749,
VL2RE64V = 750,
VL2RE8V = 751,
VL4RV = 752,
VL4RE16V = 753,
VL4RE32V = 754,
VL4RE64V = 755,
VL4RE8V = 756,
VL8RV = 757,
VL8RE16V = 758,
VL8RE32V = 759,
VL8RE64V = 760,
VL8RE8V = 761,
VLE16V = 762,
VLE16FFV = 763,
VLE1V = 764,
VLE32V = 765,
VLE32FFV = 766,
VLE64V = 767,
VLE64FFV = 768,
VLE8V = 769,
VLE8FFV = 770,
VLMV = 771,
VLOXEI16V = 772,
VLOXEI32V = 773,
VLOXEI64V = 774,
VLOXEI8V = 775,
VLSE16V = 776,
VLSE32V = 777,
VLSE64V = 778,
VLSE8V = 779,
VLUXEI16V = 780,
VLUXEI32V = 781,
VLUXEI64V = 782,
VLUXEI8V = 783,
VMACCVV = 784,
VMACCVX = 785,
VMADCVI = 786,
VMADCVIM = 787,
VMADCVV = 788,
VMADCVVM = 789,
VMADCVX = 790,
VMADCVXM = 791,
VMADDVV = 792,
VMADDVX = 793,
VMANDMM = 794,
VMANDNMM = 795,
VMANDNOTMM = 796,
VMAXVV = 797,
VMAXVX = 798,
VMAXUVV = 799,
VMAXUVX = 800,
VMERGEVIM = 801,
VMERGEVVM = 802,
VMERGEVXM = 803,
VMFEQVF = 804,
VMFEQVV = 805,
VMFGEVF = 806,
VMFGTVF = 807,
VMFLEVF = 808,
VMFLEVV = 809,
VMFLTVF = 810,
VMFLTVV = 811,
VMFNEVF = 812,
VMFNEVV = 813,
VMINVV = 814,
VMINVX = 815,
VMINUVV = 816,
VMINUVX = 817,
VMNANDMM = 818,
VMNORMM = 819,
VMORMM = 820,
VMORNMM = 821,
VMORNOTMM = 822,
VMSBCVV = 823,
VMSBCVVM = 824,
VMSBCVX = 825,
VMSBCVXM = 826,
VMSBFM = 827,
VMSEQVI = 828,
VMSEQVV = 829,
VMSEQVX = 830,
VMSGTVI = 831,
VMSGTVX = 832,
VMSGTUVI = 833,
VMSGTUVX = 834,
VMSIFM = 835,
VMSLEVI = 836,
VMSLEVV = 837,
VMSLEVX = 838,
VMSLEUVI = 839,
VMSLEUVV = 840,
VMSLEUVX = 841,
VMSLTVV = 842,
VMSLTVX = 843,
VMSLTUVV = 844,
VMSLTUVX = 845,
VMSNEVI = 846,
VMSNEVV = 847,
VMSNEVX = 848,
VMSOFM = 849,
VMULVV = 850,
VMULVX = 851,
VMULHVV = 852,
VMULHVX = 853,
VMULHSUVV = 854,
VMULHSUVX = 855,
VMULHUVV = 856,
VMULHUVX = 857,
VMV1RV = 858,
VMV2RV = 859,
VMV4RV = 860,
VMV8RV = 861,
VMVSX = 862,
VMVVI = 863,
VMVVV = 864,
VMVVX = 865,
VMVXS = 866,
VMXNORMM = 867,
VMXORMM = 868,
VNCLIPWI = 869,
VNCLIPWV = 870,
VNCLIPWX = 871,
VNCLIPUWI = 872,
VNCLIPUWV = 873,
VNCLIPUWX = 874,
VNMSACVV = 875,
VNMSACVX = 876,
VNMSUBVV = 877,
VNMSUBVX = 878,
VNSRAWI = 879,
VNSRAWV = 880,
VNSRAWX = 881,
VNSRLWI = 882,
VNSRLWV = 883,
VNSRLWX = 884,
VORVI = 885,
VORVV = 886,
VORVX = 887,
VPOPCM = 888,
VREDANDVS = 889,
VREDMAXVS = 890,
VREDMAXUVS = 891,
VREDMINVS = 892,
VREDMINUVS = 893,
VREDORVS = 894,
VREDSUMVS = 895,
VREDXORVS = 896,
VREMVV = 897,
VREMVX = 898,
VREMUVV = 899,
VREMUVX = 900,
VREV8V = 901,
VRGATHERVI = 902,
VRGATHERVV = 903,
VRGATHERVX = 904,
VRGATHEREI16VV = 905,
VROLVV = 906,
VROLVX = 907,
VRORVI = 908,
VRORVV = 909,
VRORVX = 910,
VRSUBVI = 911,
VRSUBVX = 912,
VS1RV = 913,
VS2RV = 914,
VS4RV = 915,
VS8RV = 916,
VSADDVI = 917,
VSADDVV = 918,
VSADDVX = 919,
VSADDUVI = 920,
VSADDUVV = 921,
VSADDUVX = 922,
VSBCVVM = 923,
VSBCVXM = 924,
VSE16V = 925,
VSE1V = 926,
VSE32V = 927,
VSE64V = 928,
VSE8V = 929,
VSETIVLI = 930,
VSETVL = 931,
VSETVLI = 932,
VSEXTVF2 = 933,
VSEXTVF4 = 934,
VSEXTVF8 = 935,
VSHA2CHVV = 936,
VSHA2CLVV = 937,
VSHA2MSVV = 938,
VSLIDE1DOWNVX = 939,
VSLIDE1UPVX = 940,
VSLIDEDOWNVI = 941,
VSLIDEDOWNVX = 942,
VSLIDEUPVI = 943,
VSLIDEUPVX = 944,
VSLLVI = 945,
VSLLVV = 946,
VSLLVX = 947,
VSM3CVI = 948,
VSM3MEVV = 949,
VSM4KVI = 950,
VSM4RVS = 951,
VSM4RVV = 952,
VSMV = 953,
VSMULVV = 954,
VSMULVX = 955,
VSOXEI16V = 956,
VSOXEI32V = 957,
VSOXEI64V = 958,
VSOXEI8V = 959,
VSRAVI = 960,
VSRAVV = 961,
VSRAVX = 962,
VSRLVI = 963,
VSRLVV = 964,
VSRLVX = 965,
VSSE16V = 966,
VSSE32V = 967,
VSSE64V = 968,
VSSE8V = 969,
VSSRAVI = 970,
VSSRAVV = 971,
VSSRAVX = 972,
VSSRLVI = 973,
VSSRLVV = 974,
VSSRLVX = 975,
VSSUBVV = 976,
VSSUBVX = 977,
VSSUBUVV = 978,
VSSUBUVX = 979,
VSUBVV = 980,
VSUBVX = 981,
VSUXEI16V = 982,
VSUXEI32V = 983,
VSUXEI64V = 984,
VSUXEI8V = 985,
VWADDVV = 986,
VWADDVX = 987,
VWADDWV = 988,
VWADDWX = 989,
VWADDUVV = 990,
VWADDUVX = 991,
VWADDUWV = 992,
VWADDUWX = 993,
VWMACCVV = 994,
VWMACCVX = 995,
VWMACCSUVV = 996,
VWMACCSUVX = 997,
VWMACCUVV = 998,
VWMACCUVX = 999,
VWMACCUSVX = 1000,
VWMULVV = 1001,
VWMULVX = 1002,
VWMULSUVV = 1003,
VWMULSUVX = 1004,
VWMULUVV = 1005,
VWMULUVX = 1006,
VWREDSUMVS = 1007,
VWREDSUMUVS = 1008,
VWSLLVI = 1009,
VWSLLVV = 1010,
VWSLLVX = 1011,
VWSUBVV = 1012,
VWSUBVX = 1013,
VWSUBWV = 1014,
VWSUBWX = 1015,
VWSUBUVV = 1016,
VWSUBUVX = 1017,
VWSUBUWV = 1018,
VWSUBUWX = 1019,
VXORVI = 1020,
VXORVV = 1021,
VXORVX = 1022,
VZEXTVF2 = 1023,
VZEXTVF4 = 1024,
VZEXTVF8 = 1025,
WFI = 1026,
WRSNTO = 1027,
WRSSTO = 1028,
XNOR = 1029,
XOR = 1030,
XORI = 1031,
XPERM4 = 1032,
XPERM8 = 1033,
ZEXTB = 1034,
ZEXTH = 1035,
ZEXTHRV32 = 1036,
ZEXTW = 1037,
ZIP = 1038,
Invalid = 1039,
}Variants§
ADD = 0
Integer add
Add the value in rs1 to rs2, and store the result in rd. Any overflow is thrown away.
§Forms
Assembly: add xd, xs1, xs2
ADDUW = 1
Add unsigned word
This instruction performs an XLEN-wide addition between rs2 and the zero-extended least-significant word of rs1.
§Forms
Assembly: add.uw xd, xs1, xs2
ADDI = 2
Add immediate
Add an immediate to the value in rs1, and store the result in rd
§Forms
Assembly: addi xd, xs1, imm
ADDIW = 3
Add immediate word
Add an immediate to the 32-bit value in rs1, and store the sign extended result in rd
§Forms
Assembly: addiw xd, xs1, imm
ADDW = 4
Add word
Add the 32-bit values in rs1 to rs2, and store the sign-extended result in rd. Any overflow is thrown away.
§Forms
Assembly: addw xd, xs1, xs2
AES32DSI = 5
AES32DSMI = 6
AES32ESI = 7
AES32ESMI = 8
AES64DS = 9
AES64DSM = 10
AES64ES = 11
AES64ESM = 12
AES64IM = 13
AES64KS1I = 14
AES64KS2 = 15
AMOADDB = 16
AMOADDD = 17
Atomic fetch-and-add doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- Add the value of register rs2 to the loaded value
- Write the sum to the address in rs1
§Forms
Assembly: amoadd.d xd, xs2, (xs1)
AMOADDH = 18
AMOADDW = 19
Atomic fetch-and-add word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- Add the least-significant word of register rs2 to the loaded value
- Write the sum to the address in rs1
§Forms
Assembly: amoadd.w xd, xs2, (xrs1)
AMOANDB = 20
AMOANDD = 21
Atomic fetch-and-and doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- AND the value of register rs2 to the loaded value
- Write the result to the address in rs1
§Forms
Assembly: amoand.d xd, xs2, (xrs1)
AMOANDH = 22
AMOANDW = 23
Atomic fetch-and-and word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- AND the least-significant word of register rs2 to the loaded value
- Write the result to the address in rs1
§Forms
Assembly: amoand.w xd, xs2, (xrs1)
AMOCASB = 24
AMOCASD = 25
AMOCASH = 26
AMOCASQ = 27
AMOCASW = 28
AMOMAXB = 29
AMOMAXD = 30
Atomic MAX doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- Signed compare the value of register rs2 to the loaded value, and select the maximum value
- Write the maximum to the address in rs1
§Forms
Assembly: amomax.d xd, xs2, (xrs1)
AMOMAXH = 31
AMOMAXW = 32
Atomic MAX word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- Signed compare the least-significant word of register rs2 to the loaded value, and select the maximum value
- Write the maximum to the address in rs1
§Forms
Assembly: amomax.w xd, xs2, (xrs1)
AMOMAXUB = 33
AMOMAXUD = 34
Atomic MAX unsigned doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- Unsigned compare the value of register rs2 to the loaded value, and select the maximum value
- Write the maximum to the address in rs1
§Forms
Assembly: amomaxu.d xd, xs2, (xrs1)
AMOMAXUH = 35
AMOMAXUW = 36
Atomic MAX unsigned word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- Unsigned compare the least-significant word of register rs2 to the loaded value, and select the maximum value
- Write the maximum to the address in rs1
§Forms
Assembly: amomaxu.w xd, xs2, (xrs1)
AMOMINB = 37
AMOMIND = 38
Atomic MIN doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- Signed compare the value of register rs2 to the loaded value, and select the minimum value
- Write the minimum to the address in rs1
§Forms
Assembly: amomin.d xd, xs2, (xrs1)
AMOMINH = 39
AMOMINW = 40
Atomic MIN word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- Signed compare the least-significant word of register rs2 to the loaded value, and select the minimum value
- Write the result to the address in rs1
§Forms
Assembly: amomin.w xd, xs2, (xrs1)
AMOMINUB = 41
AMOMINUD = 42
Atomic MIN unsigned doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- Unsigned compare the value of register rs2 to the loaded value, and select the minimum value
- Write the minimum to the address in rs1
§Forms
Assembly: amominu.d xd, xs2, (xrs1)
AMOMINUH = 43
AMOMINUW = 44
Atomic MIN unsigned word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- Unsigned compare the least-significant word of register rs2 to the loaded word, and select the minimum value
- Write the result to the address in rs1
§Forms
Assembly: amominu.w xd, xs2, (xrs1)
AMOORB = 45
AMOORD = 46
Atomic fetch-and-or doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- OR the value of register rs2 to the loaded value
- Write the result to the address in rs1
§Forms
Assembly: amoor.d xd, xs2, (xrs1)
AMOORH = 47
AMOORW = 48
Atomic fetch-and-or word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- OR the least-significant word of register rs2 to the loaded value
- Write the result to the address in rs1
§Forms
Assembly: amoor.w xd, xs2, (xrs1)
AMOSWAPB = 49
AMOSWAPD = 50
Atomic SWAP doubleword
Atomically:
- Load the doubleword at address rs1
- Write the value into rd
- Store the value of register rs2 to the address in rs1
§Forms
Assembly: amoswap.d xd, xs2, (xrs1)
AMOSWAPH = 51
AMOSWAPW = 52
Atomic SWAP word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- Store the least-significant word of register rs2 to the address in rs1
§Forms
Assembly: amoswap.w xd, xs2, (xrs1)
AMOXORB = 53
AMOXORD = 54
Atomic fetch-and-xor doubleword
Atomically:
- Load the doubleword at address rs1
- Write the loaded value into rd
- XOR the value of register rs2 to the loaded value
- Write the result to the address in rs1
§Forms
Assembly: amoxor.d xd, xs2, (xrs1)
AMOXORH = 55
AMOXORW = 56
Atomic fetch-and-xor word
Atomically:
- Load the word at address rs1
- Write the sign-extended value into rd
- XOR the least-significant word of register rs2 to the loaded value
- Write the result to the address in rs1
§Forms
Assembly: amoxor.w xd, xs2, (xrs1)
AND = 57
ANDI = 58
And immediate
And an immediate to the value in rs1, and store the result in rd
§Forms
Assembly: andi xd, xs1, imm
ANDN = 59
AND with inverted operand
This instruction performs the bitwise logical AND operation between rs1 and the
bitwise inversion of rs2.
§Forms
Assembly: andn xd, xs1, xs2
AUIPC = 60
BCLR = 61
Single-Bit clear (Register)
This instruction returns rs1 with a single bit cleared at the index specified in rs2. The index is read from the lower log2(XLEN) bits of rs2.
§Forms
Assembly: bclr xd, xs1, xs2
BCLRI = 62
Single-Bit clear (Immediate)
This instruction returns rs1 with a single bit cleared at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: bclri xd, xs1, shamt
BCLRIRV32 = 63
Single-Bit clear (Immediate)
This instruction returns rs1 with a single bit cleared at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: bclri.rv32 xd, xs1, shamt
BEQ = 64
Branch if equal
Branch to PC + imm if the value in register rs1 is equal to the value in register rs2.
Raise a MisalignedAddress exception if PC + imm is misaligned.
§Forms
Assembly: beq xs1, xs2, imm
BEQZ = 65
BEXT = 66
Single-Bit extract (Register)
This instruction returns a single bit extracted from rs1 at the index specified in rs2. The index is read from the lower log2(XLEN) bits of rs2.
§Forms
Assembly: bext xd, xs1, xs2
BEXTI = 67
Single-Bit extract (Immediate)
This instruction returns a single bit extracted from rs1 at the index specified in rs2. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: bexti xd, xs1, shamt
BEXTIRV32 = 68
Single-Bit extract (Immediate)
This instruction returns a single bit extracted from rs1 at the index specified in rs2. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: bexti.rv32 xd, xs1, shamt
BGE = 69
Branch if greater than or equal
Branch to PC + imm if the signed value in register rs1 is greater than or equal to the signed value in register rs2.
Raise a MisalignedAddress exception if PC + imm is misaligned.
§Forms
Assembly: bge xs1, xs2, imm
BGEU = 70
Branch if greater than or equal unsigned
Branch to PC + imm if the unsigned value in register rs1 is greater than or equal to the unsigned value in register rs2.
Raise a MisalignedAddress exception if PC + imm is misaligned.
§Forms
Assembly: bgeu xs1, xs2, imm
BGEZ = 71
BGT = 72
BGTU = 73
BGTZ = 74
BINV = 75
Single-Bit invert (Register)
This instruction returns rs1 with a single bit inverted at the index specified in rs2. The index is read from the lower log2(XLEN) bits of rs2.
§Forms
Assembly: binv xd, xs1, xs2
BINVI = 76
Single-Bit invert (Immediate)
This instruction returns rs1 with a single bit inverted at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: binvi xd, xs1, shamt
BINVIRV32 = 77
Single-Bit invert (Immediate)
This instruction returns rs1 with a single bit inverted at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: binvi.rv32 xd, xs1, shamt
BLE = 78
BLEU = 79
BLEZ = 80
BLT = 81
Branch if less than
Branch to PC + imm if the signed value in register rs1 is less than the signed value in register rs2.
Raise a MisalignedAddress exception if PC + imm is misaligned.
§Forms
Assembly: blt xs1, xs2, imm
BLTU = 82
Branch if less than unsigned
Branch to PC + imm if the unsigned value in register rs1 is less than the unsigned value in register rs2.
Raise a MisalignedAddress exception if PC + imm is misaligned.
§Forms
Assembly: bltu xs1, xs2, imm
BLTZ = 83
BNE = 84
Branch if not equal
Branch to PC + imm if the value in register rs1 is not equal to the value in register rs2.
Raise a MisalignedAddress exception if PC + imm is misaligned.
§Forms
Assembly: bne xs1, xs2, imm
BNEZ = 85
BREV8 = 86
Reverse bits in bytes
This instruction reverses the order of the bits in every byte of a register.
§Forms
Assembly: brev8 xd, xs1
BSET = 87
Single-Bit set (Register)
This instruction returns rs1 with a single bit set at the index specified in rs2. The index is read from the lower log2(XLEN) bits of rs2.
§Forms
Assembly: bset xd, xs1, xs2
BSETI = 88
Single-Bit set (Immediate)
This instruction returns rs1 with a single bit set at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: bseti xd, xs1, shamt
BSETIRV32 = 89
Single-Bit set (Immediate)
This instruction returns rs1 with a single bit set at the index specified in shamt. The index is read from the lower log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: bseti.rv32 xd, xs1, shamt
CADD = 90
Add
Add the value in rs2 to rd, and store the result in rd.
C.ADD expands into add rd, rd, rs2.
§Forms
Assembly: c.add xd, rs2
CADDI = 91
Add a sign-extended non-zero immediate
C.ADDI adds the non-zero sign-extended 6-bit immediate to the value in register rd then writes the result to rd.
C.ADDI expands into addi rd, rd, imm.
C.ADDI is only valid when rd ≠ x0 and imm ≠ 0.
The code points with rd=x0 encode the C.NOP instruction; the remaining code points with imm=0 encode HINTs.
§Forms
Assembly: c.addi xd, imm
CADDI16SP = 92
Add a sign-extended non-zero immediate
C.ADDI16SP adds the non-zero sign-extended 6-bit immediate to the value in the stack pointer (sp=x2), where the immediate is scaled to represent multiples of 16 in the range (-512,496).
C.ADDI16SP is used to adjust the stack pointer in procedure prologues and epilogues.
It expands into addi x2, x2, nzimm\[9:4\].
C.ADDI16SP is only valid when nzimm ≠ 0; the code point with nzimm=0 is reserved.
§Forms
Assembly: c.addi16sp imm
CADDI4SPN = 93
Add a zero-extended non-zero immediate, scaled by 4, to the stack pointer
Adds a zero-extended non-zero immediate, scaled by 4, to the stack pointer, x2, and writes the result to rd’.
This instruction is used to generate pointers to stack-allocated variables.
It expands to addi rd', x2, nzuimm\[9:2\].
C.ADDI4SPN is only valid when nzuimm ≠ 0; the code points with nzuimm=0 are reserved.
§Forms
Assembly: c.addi4spn xd, imm
CADDIW = 94
Add a sign-extended non-zero immediate
C.ADDIW is an RV64C/RV128C-only instruction that performs the same computation as C.ADDI but produces a 32-bit result, then sign-extends result to 64 bits.
C.ADDIW expands into addiw rd, rd, imm.
The immediate can be zero for C.ADDIW, where this corresponds to sext.w rd.
C.ADDIW is only valid when rd ≠ x0; the code points with rd=x0 are reserved.
§Forms
Assembly: c.addiw xd, imm
CADDW = 95
Add word
Add the 32-bit values in rs2 from rd, and store the result in rd.
The rd and rs2 register indexes should be used as rd+8 and rs2+8 (registers x8-x15).
C.ADDW expands into addw rd, rd, rs2.
§Forms
Assembly: c.addw xd, rs2
CAND = 96
And
And rd with rs2, and store the result in rd
The rd and rs2 register indexes should be used as rd+8 and rs2+8 (registers x8-x15).
C.AND expands into and rd, rd, rs2.
§Forms
Assembly: c.and xd, rs2
CANDI = 97
And immediate
And an immediate to the value in rd, and store the result in rd.
The rd register index should be used as rd+8 (registers x8-x15).
C.ANDI expands into andi rd, rd, imm.
§Forms
Assembly: c.andi xd, imm
CBEQZ = 98
Branch if Equal Zero
C.BEQZ performs conditional control transfers. The offset is sign-extended and added to the pc to form the branch target address. It can therefore target a ±256 B range. C.BEQZ takes the branch if the value in register rs1’ is zero.
It expands to beq rs1, x0, offset.
§Forms
Assembly: c.beqz xs1, imm
CBNEZ = 99
Branch if NOT Equal Zero
C.BEQZ performs conditional control transfers. The offset is sign-extended and added to the pc to form the branch target address. It can therefore target a ±256 B range. C.BEQZ takes the branch if the value in register rs1’ is NOT zero.
It expands to beq rs1, x0, offset.
§Forms
Assembly: c.bnez xs1, imm
CEBREAK = 100
Breakpoint exception.
The C.EBREAK instruction is used by debuggers to cause control to be transferred back to a debugging environment. Unless overridden by an external debug environment, C.EBREAK raises a breakpoint exception and performs no other operation.
[NOTE]
As described in the C Standard Extension for Compressed Instructions, the c.ebreak
instruction performs the same operation as the EBREAK instruction.
EBREAK causes the receiving privilege mode’s epc register to be set to the address of
the EBREAK instruction itself, not the address of the following instruction.
As EBREAK causes a synchronous exception, it is not considered to retire,
and should not increment the minstret CSR.
§Forms
Assembly: c.ebreak " "
CFLD = 101
Load double-precision
Loads a double precision floating-point value from memory into register rd.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the base address in register rs1.
It expands to fld rd, offset(rs1).
§Forms
Assembly: c.fld xd, imm(xs1)
CFLDSP = 102
Load doubleword into floating-point register from stack
Loads a double-precision floating-point value from memory into floating-point register rd.
It computes its effective address by adding the zero-extended offset, scaled by 8,
to the stack pointer, x2.
It expands to fld rd, offset(x2).
§Forms
Assembly: c.fldsp fd, imm(sp)
CFLW = 103
Load single-precision
Loads a single precision floating-point value from memory into register rd.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the base address in register rs1.
It expands to flw rd, offset(rs1).
§Forms
Assembly: c.flw xd, imm(xs1)
CFLWSP = 104
Load word into floating-point register from stack
Loads a single-precision floating-point value from memory into floating-point register rd.
It computes its effective address by adding the zero-extended offset, scaled by 4,
to the stack pointer, x2.
It expands to flw rd, offset(x2).
§Forms
Assembly: c.flwsp fd, imm(sp)
CFSD = 105
Store double-precision
Stores a double precision floating-point value in register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the base address in register rs1.
It expands to fsd rs2, offset(rs1).
§Forms
Assembly: c.fsd xs2, imm(xs1)
CFSDSP = 106
Store double-precision value to stack
Stores a double-precision floating-point value in floating-point register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the stack pointer, x2.
It expands to fsd rs2, offset(x2).
§Forms
Assembly: c.fsdsp fs2, imm(sp)
CFSW = 107
Store single-precision
Stores a single precision floating-point value in register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the base address in register rs1.
It expands to fsw rs2, offset(rs1).
§Forms
Assembly: c.fsw xs2, imm(xs1)
CFSWSP = 108
Store single-precision value to stack
Stores a single-precision floating-point value in floating-point register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the stack pointer, x2.
It expands to fsw rs2, offset(x2).
§Forms
Assembly: c.fswsp fs2, imm(sp)
CJ = 109
Jump
C.J performs an unconditional control transfer. The offset is sign-extended and added to the pc to form the jump target address. C.J can therefore target a ±2 KiB range.
It expands to jal x0, offset.
§Forms
Assembly: c.j imm
CJAL = 110
Jump and Link
C.JAL is an RV32C-only instruction that performs the same operation as C.J, but additionally writes the address of the instruction following the jump (pc+2) to the link register, x1.
It expands to jal x1, offset.
§Forms
Assembly: c.jal imm
CJALR = 111
Jump and Link Register.
C.JALR (jump and link register) performs the same operation as C.JR, but additionally writes the address of the instruction following the jump (pc+2) to the link register, x1. C.JALR expands to jalr x1, 0(rs1).
§Forms
Assembly: c.jalr xs1
CJR = 112
Jump Register
C.JR (jump register) performs an unconditional control transfer to the address in register rs1. C.JR expands to jalr x0, 0(rs1).
§Forms
Assembly: c.jr xs1
CLBU = 113
Load unsigned byte, 16-bit encoding
Loads a 8-bit value from memory into register rd.
It computes an effective address by adding the zero-extended offset, to the base address in register rs1.
It expands to lbu rd, offset(rs1).
§Forms
Assembly: c.lbu xd, imm(xs1)
CLD = 114
Load double
Loads a 64-bit value from memory into register rd.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the base address in register rs1.
It expands to ld rd, offset(rs1).
§Forms
Assembly: c.ld xd, imm(xs1)
CLDSP = 115
Load doubleword from stack pointer
C.LDSP is an RV64C/RV128C-only instruction that loads a 64-bit value from memory
into register rd.
It computes its effective address by adding the zero-extended offset, scaled by 8,
to the stack pointer, x2.
It expands to ld rd, offset(x2).
C.LDSP is only valid when rd ≠ x0 the code points with rd=x0 are reserved.
§Forms
Assembly: c.ldsp xd, imm(sp)
CLH = 116
Load signed halfword, 16-bit encoding
Loads a 16-bit value from memory into register rd.
It computes an effective address by adding the zero-extended offset, to the base address in register rs1.
It expands to lh rd, offset(rs1).
§Forms
Assembly: c.lh xd, imm(xs1)
CLHU = 117
Load unsigned halfword, 16-bit encoding
Loads a 16-bit value from memory into register rd.
It computes an effective address by adding the zero-extended offset, to the base address in register rs1.
It expands to lhu rd, offset(rs1).
§Forms
Assembly: c.lhu xd, imm(xs1)
CLI = 118
Load the sign-extended 6-bit immediate
C.LI loads the sign-extended 6-bit immediate, imm, into register rd.
C.LI expands into addi rd, x0, imm.
C.LI is only valid when rd ≠ x0; the code points with rd=x0 encode HINTs.
§Forms
Assembly: c.li xd, imm
CLUI = 119
Load the non-zero 6-bit immediate field into bits 17-12 of the destination register
C.LUI loads the non-zero 6-bit immediate field into bits 17-12 of the destination register, clears the bottom 12 bits, and sign-extends bit 17 into all higher bits of the destination.
C.LUI expands into lui rd, imm.
C.LUI is only valid when rd≠x0 and rd≠x2, and when the immediate is not equal to zero.
The code points with imm=0 are reserved; the remaining code points with rd=x0 are HINTs; and the remaining code points with rd=x2 correspond to the C.ADDI16SP instruction
§Forms
Assembly: c.lui xd, imm
CLW = 120
Load word
Loads a 32-bit value from memory into register rd.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the base address in register rs1.
It expands to lw rd, offset(rs1).
§Forms
Assembly: c.lw xd, imm(xs1)
CLWSP = 121
Load word from stack pointer
Loads a 32-bit value from memory into register rd.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the stack pointer, x2.
It expands to lw rd, offset(x2).
C.LWSP is only valid when rd ≠ x0. The code points with rd=x0 are reserved.
§Forms
Assembly: c.lwsp xd, imm(sp)
CMOP1 = 122
CMOP11 = 123
CMOP13 = 124
CMOP15 = 125
CMOP3 = 126
CMOP5 = 127
CMOP7 = 128
CMOP9 = 129
CMOPN = 130
CMUL = 131
Multiply, 16-bit encoding
This instruction multiplies XLEN bits of the source operands from rsd’ and rs2’ and writes the lowest XLEN bits of the result to rsd’.
§Forms
Assembly: c.mul xd, xs2
CMV = 132
Move Register
C.MV (move register) performs copy of the data in register rs2 to register rd C.MV expands to addi rd, x0, rs2.
§Forms
Assembly: c.mv xd, xs2
CNOP = 133
CNOT = 134
Bitwise not, 16-bit encoding
This instruction takes a single source/destination operand. This instruction takes the one’s complement of rd’/rs1’ and writes the result to the same register.
§Forms
Assembly: c.not xd
CNTLALL = 135
CNTLP1 = 136
CNTLPALL = 137
CNTLS1 = 138
COR = 139
Or
Or rd with rs2, and store the result in rd
The rd and rs2 register indexes should be used as rd+8 and rs2+8 (registers x8-x15).
C.OR expands into or rd, rd, rs2.
§Forms
Assembly: c.or xd, rs2
CSB = 140
Store unsigned byte, 16-bit encoding
Stores a 8-bit value from register rs2 into memory.
It computes an effective address by adding the zero-extended offset, to the base address in register rs1.
It expands to sb rs2, offset(rs1).
§Forms
Assembly: c.sb xs2, imm(xs1)
CSD = 141
Store double
Stores a 64-bit value in register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the base address in register rs1.
It expands to sd rs2, offset(rs1).
§Forms
Assembly: c.sd xs2, imm(xs1)
CSDSP = 142
Store doubleword to stack
Stores a 64-bit value in register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 8,
to the stack pointer, x2.
It expands to sd rs2, offset(x2).
§Forms
Assembly: c.sdsp xs2, imm(sp)
CSEXTB = 143
Sign-extend byte, 16-bit encoding
This instruction takes a single source/destination operand. This instruction sign-extends the least-significant byte of the source to XLEN by copying the most-significant bit in the byte (i.e., bit 7) to all of the more-significant bits.
§Forms
Assembly: c.sext.b xd
CSEXTH = 144
Sign-extend halfword, 16-bit encoding
This instruction takes a single source/destination operand. This instruction sign-extends the least-significant halfword of the source to XLEN by copying the most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits.
§Forms
Assembly: c.sext.h xd
CSEXTW = 145
CSH = 146
Store unsigned halfword, 16-bit encoding
Stores a 16-bit value from register rs2 into memory.
It computes an effective address by adding the zero-extended offset, to the base address in register rs1.
It expands to sh rs2, offset(rs1).
§Forms
Assembly: c.sh xs2, imm(xs1)
CSLLI = 147
Shift left logical immediate
Shift the value in rd left by shamt, and store the result back in rd.
C.SLLI expands into slli rd, rd, shamt.
§Forms
Assembly: c.slli xd, shamt
CSLLIRV32 = 148
Shift left logical immediate
Shift the value in rd left by shamt, and store the result back in rd.
C.SLLI expands into slli rd, rd, shamt.
§Forms
Assembly: c.slli.rv32 xd, shamt
CSRAI = 149
Shift right arithmetical immediate
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in rd right by shamt, and store the result in rd.
The rd register index should be used as rd+8 (registers x8-x15).
C.SRAI expands into srai rd, rd, shamt.
§Forms
Assembly: c.srai xd, shamt
CSRAIRV32 = 150
Shift right arithmetical immediate
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in rd right by shamt, and store the result in rd.
The rd register index should be used as rd+8 (registers x8-x15).
C.SRAI expands into srai rd, rd, shamt.
§Forms
Assembly: c.srai.rv32 xd, shamt
CSRLI = 151
Shift right logical immediate
Shift the value in rd right by shamt, and store the result back in rd.
The rd register index should be used as rd+8 (registers x8-x15).
C.SRLI expands into srli rd, rd, shamt.
§Forms
Assembly: c.srli xd, shamt
CSRLIRV32 = 152
Shift right logical immediate
Shift the value in rd right by shamt, and store the result back in rd.
The rd register index should be used as rd+8 (registers x8-x15).
C.SRLI expands into srli rd, rd, shamt.
§Forms
Assembly: c.srli.rv32 xd, shamt
CSSPOPCHKX5 = 153
CSSPUSHX1 = 154
CSUB = 155
Subtract
Subtract the value in rs2 from rd, and store the result in rd.
The rd and rs2 register indexes should be used as rd+8 and rs2+8 (registers x8-x15).
C.SUB expands into sub rd, rd, rs2.
§Forms
Assembly: c.sub xd, rs2
CSUBW = 156
Subtract word
Subtract the 32-bit values in rs2 from rd, and store the result in rd.
The rd and rs2 register indexes should be used as rd+8 and rs2+8 (registers x8-x15).
C.SUBW expands into subw rd, rd, rs2.
§Forms
Assembly: c.subw xd, rs2
CSW = 157
Store word
Stores a 32-bit value in register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the base address in register rs1.
It expands to sw rs2, offset(rs1).
§Forms
Assembly: c.sw xs2, imm(xs1)
CSWSP = 158
Store word to stack
Stores a 32-bit value in register rs2 to memory.
It computes an effective address by adding the zero-extended offset, scaled by 4,
to the stack pointer, x2.
It expands to sw rs2, offset(x2).
§Forms
Assembly: c.swsp xs2, imm(sp)
CXOR = 159
Exclusive Or
Exclusive or rd with rs2, and store the result in rd
The rd and rs2 register indexes should be used as rd+8 and rs2+8 (registers x8-x15).
C.XOR expands into xor rd, rd, rs2.
§Forms
Assembly: c.xor xd, rs2
CZEXTB = 160
Zero-extend byte, 16-bit encoding
This instruction takes a single source/destination operand. This instruction zero-extends the least-significant byte of the source to XLEN by inserting 0’s into all of the bits more significant than 7.
§Forms
Assembly: c.zext.b xd
CZEXTH = 161
Zero-extend halfword, 16-bit encoding
This instruction takes a single source/destination operand. This instruction zero-extends the least-significant halfword of the source to XLEN by inserting 0’s into all of the bits more significant than 15.
§Forms
Assembly: c.zext.h xd
CZEXTW = 162
Zero-extend word, 16-bit encoding
This instruction takes a single source/destination operand. It zero-extends the least-significant word of the operand to XLEN bits by inserting zeros into all of the bits more significant than 31.
§Forms
Assembly: c.zext.w xd
CBOCLEAN = 163
Cache Block Clean
Cleans an entire cache block globally throughout the system.
Exactly what happens is coherence protocol-dependent, but in general it is expected that after this operation():
- The cache block will be in the clean (not dirty) state in any coherent cache holding a valid copy of the line.
- The data will be cleaned to a point such that an incoherent load can observe the cleaned data.
cbo.clean is ordered by FENCE instructions but not FENCE.I or SFENCE.VMA.
<%- if CACHE_BLOCK_SIZE.bit_length > [PMP_GRANULARITY, PMA_GRANULARITY].min -%>
Both PMP and PMA access control must be the same for all bytes in the block; otherwise, cbo.clean has UNSPECIFIED behavior.
<%- end -%>
Clean operations are treated as stores for page and access permissions. If permission checks fail, one of the following exceptions will occur:
<%- if ext?(:H) -%>
Store/AMO Guest-Page Faultif virtual memory translation fails during G-stage translation. <%- end -%>Store/AMO Page Faultif virtual memory translation fails <% if ext?(:H) %>when V=0 or during VS-stage translation<% end %>Store/AMO Access Faultif a PMP or PMA access check fails
<%- if CACHE_BLOCK_SIZE.bit_length <= [PMP_GRANULARITY, PMA_GRANULARITY].min -%> Because cache blocks are naturally aligned and always fit in a single PMP or PMA regions, the PMP and PMA access checks only need to check a single address in the line. <%- end -%>
CBO operations never raise a misaligned address fault.
§Forms
Assembly: cbo.clean "TODO"
CBOFLUSH = 164
Cache Block Flush
Flushes an entire cache block by cleaning it and then invalidating it in all caches.
cbo.flush is ordered by FENCE instructions but not FENCE.I or SFENCE.VMA.
<%- if CACHE_BLOCK_SIZE.bit_length > [PMP_GRANULARITY, PMA_GRANULARITY].min -%>
Both PMP and PMA access control must be the same for all bytes in the block; otherwise, cbo.flush has UNSPECIFIED behavior.
<%- end -%>
Flush operations are treated as stores for page and access permissions. If permission checks fail, one of the following exceptions will occur:
<%- if ext?(:H) -%>
Store/AMO Guest-Page Faultif virtual memory translation fails during G-stage translation. <%- end -%>Store/AMO Page Faultif virtual memory translation fails <% if ext?(:H) %>when V=0 or during VS-stage translation<% end %>Store/AMO Access Faultif a PMP or PMA access check fails.
<%- if CACHE_BLOCK_SIZE.bit_length <= [PMP_GRANULARITY, PMA_GRANULARITY].min -%> Because cache blocks are naturally aligned and always fit in a single PMP or PMA regions, the PMP and PMA access checks only need to check a single address in the line. <%- end -%>
CBO operations never raise a misaligned address fault.
§Forms
Assembly: cbo.flush "TODO"
CBOINVAL = 165
Cache Block Invalidate
Either invalidates or flushes (clean + invalidate) a cache block, depending on the current mode and value of
menvcfg.CBIE, senvcfg.CBIE, and/or henvcfg.CBIE.
The instruction is an invalidate (without a clean) when:
- In M-mode
- In (H)S-mode and
menvcfg.CBIE== 11 - In U-mode and
menvcfg.CBIE== 11 andsenvcfg.CBIE== 11 - In VS-mode and
menvcfg.CBIE== 11 andhenvcfg.CBIE== 11 - In VU-mode and
menvcfg.CBIE== 11 andhenvcfg.CBIE== 11 andsenvcfg.CBIE== 11
Otherwise, if the instruction does not trap (see Access section), the operation is a flush. The table below summarizes the options.
[%autowidth,cols=“1,1,1,1,1,1,1,1”,separator=“!”]
!===
.2+h![.rotate]#menvcfg.CBIE# .2+h! [.rotate]#senvcfg.CBIE# .2+h! [.rotate]#henvcfg.CBIE#
5+^.>h! cbe.inval Operation
.^h! M-mode .^h! S-mode .^h! U-mode .^h! VS-mode .^h! VU-mode
! 00 ! - ! - ! Invalidate ! Illegal Instruction ! Illegal Instruction ! Virtual Instruction ! Virtual Instruction
! 01 ! 00 ! 00 ! Invalidate ! Flush ! Illegal Instruction ! Virtual Instruction ! Virtual Instruction
! 01 ! 00 ! 01 ! Invalidate ! Flush ! Illegal Instruction ! Flush ! Virtual Instruction
! 01 ! 00 ! 11 ! Invalidate ! Flush ! Illegal Instruction ! Flush ! Virtual Instruction
! 01 ! 01 ! 00 ! Invalidate ! Flush ! Flush ! Virtual Instruction ! Virtual Instruction
! 01 ! 01 ! 01 ! Invalidate ! Flush ! Flush ! Flush ! Flush
! 01 ! 01 ! 11 ! Invalidate ! Flush ! Flush ! Flush ! Flush
! 01 ! 11 ! 00 ! Invalidate ! Flush ! Flush ! Virtual Instruction ! Virtual Instruction
! 01 ! 11 ! 01 ! Invalidate ! Flush ! Flush ! Flush ! Flush
! 01 ! 11 ! 11 ! Invalidate ! Flush ! Flush ! Flush ! Flush
! 11 ! 00 ! 00 ! Invalidate ! Invalidate ! Illegal Instruction ! Virtual Instruction ! Virtual Instruction
! 11 ! 00 ! 01 ! Invalidate ! Invalidate ! Illegal Instruction ! Flush ! Virtual Instruction
! 11 ! 00 ! 11 ! Invalidate ! Invalidate ! Illegal Instruction ! Invalidate ! Virtual Instruction
! 11 ! 01 ! 00 ! Invalidate ! Invalidate ! Flush ! Virtual Instruction ! Virtual Instruction
! 11 ! 01 ! 01 ! Invalidate ! Invalidate ! Flush ! Flush ! Flush
! 11 ! 01 ! 11 ! Invalidate ! Invalidate ! Flush ! Invalidate ! Flush
! 11 ! 11 ! 00 ! Invalidate ! Invalidate ! Invalidate ! Virtual Instruction ! Virtual Instruction
! 11 ! 11 ! 01 ! Invalidate ! Invalidate ! Invalidate ! Flush ! Flush
! 11 ! 11 ! 11 ! Invalidate ! Invalidate ! Invalidate ! Invalidate ! Invalidate
!===
cbo.inval is ordered by FENCE instructions but not FENCE.I or SFENCE.VMA.
<%- if CACHE_BLOCK_SIZE.bit_length > [PMP_GRANULARITY, PMA_GRANULARITY].min -%>
Both PMP and PMA access control must be the same for all bytes in the block; otherwise, cbo.zero has UNSPECIFIED behavior.
<%- end -%>
Invalidate operations are treated as stores for page and access permissions. If permission checks fail, one of the following exceptions will occur:
<%- if ext?(:H) -%>
Store/AMO Guest-Page Faultif virtual memory translation fails during G-stage translation. <%- end -%>Store/AMO Page Faultif virtual memory translation fails <% if ext?(:H) %>when V=0 or during VS-stage translation<% end %>Store/AMO Access Faultif a PMP or PMA access check fails.
<%- if CACHE_BLOCK_SIZE.bit_length <= [PMP_GRANULARITY, PMA_GRANULARITY].min -%> Because cache blocks are naturally aligned and always fit in a single PMP or PMA regions, the PMP and PMA access checks only need to check a single address in the line. <%- end -%>
CBO operations never raise a misaligned address fault.
§Forms
Assembly: cbo.inval "TODO"
CBOZERO = 166
Cache Block Zero
Zeros an entire cache block
The block zeroing does not need to be atomic.
cbo.zero is ordered by FENCE instructions but not FENCE.I or SFENCE.VMA.
<%- if CACHE_BLOCK_SIZE.bit_length > [PMP_GRANULARITY, PMA_GRANULARITY].min -%>
Both PMP and PMA access control must be the same for all bytes in the block; otherwise, cbo.zero has UNSPECIFIED behavior.
<%- end -%>
Clean operations are treated as stores for page and access permissions. If permission checks fail, one of the following exceptions will occur:
<%- if ext?(:H) -%>
Store/AMO Guest-Page Faultif virtual memory translation fails during G-stage translation. <%- end -%>Store/AMO Page Faultif virtual memory translation fails <% if ext?(:H) %>when V=0 or during VS-stage translation<% end %>Store/AMO Access Faultif a PMP or PMA access check fails.
<%- if CACHE_BLOCK_SIZE.bit_length <= [PMP_GRANULARITY, PMA_GRANULARITY].min -%> Because cache blocks are naturally aligned and always fit in a single PMP or PMA regions, the PMP and PMA access checks only need to check a single address in the line. <%- end -%>
CBO operations never raise a misaligned address fault.
§Forms
Assembly: cbo.zero "TODO"
CLMUL = 167
Carry-less multiply (low-part)
clmul produces the lower half of the 2*XLEN carry-less product
§Forms
Assembly: clmul xd, xs1, xs2
CLMULH = 168
Carry-less multiply (high-part)
clmulh produces the upper half of the 2*XLEN carry-less product
§Forms
Assembly: clmulh xd, xs1, xs2
CLMULR = 169
Carry-less multiply (reversed)
clmulr produces bits 2XLEN-2:XLEN-1 of the 2XLEN carry-less product
§Forms
Assembly: clmulr xd, xs1, xs2
CLZ = 170
Count leading zero bits
This instruction counts the number of 0’s before the first 1, starting at the most-significant bit (i.e., XLEN-1) and progressing to bit 0. Accordingly, if the input is 0, the output is XLEN, and if the most-significant bit of the input is a 1, the output is 0.
§Forms
Assembly: clz xd, xs1
CLZW = 171
Count leading zero bits in word
This instruction counts the number of 0’s before the first 1 starting at bit 31 and progressing to bit 0. Accordingly, if the least-significant word is 0, the output is 32, and if the most-significant bit of the word (i.e., bit 31) is a 1, the output is 0.
§Forms
Assembly: clzw xd, xs1
CMJALT = 172
CMMVA01S = 173
Move two s0-s7 registers into a0-a1
This instruction moves r1s’ into a0 and r2s’ into a1. The execution is atomic, so it is not possible to observe state where only one of a0 or a1 have been updated. The encoding uses sreg number specifiers instead of xreg number specifiers to save encoding space. The mapping between them is specified in the pseudo-code below.
§Forms
Assembly: cm.mva01s r1s, r2s
CMMVSA01 = 174
Move a0-a1 into two registers of s0-s7
This instruction moves a0 into r1s’ and a1 into r2s’. r1s’ and r2s’ must be different. The execution is atomic, so it is not possible to observe state where only one of r1s’ or r2s’ has been updated. The encoding uses sreg number specifiers instead of xreg number specifiers to save encoding space. The mapping between them is specified in the pseudo-code below.
§Forms
Assembly: cm.mvsa01 r1s, r2s
CMPOP = 175
Destroy function call stack frame
Destroy stack frame: load ra and 0 to 12 saved registers from the stack frame, deallocate the stack frame.
This instruction pops (loads) the registers in reg_list from stack memory, and then adjusts the stack pointer by stack_adj.
Restrictions on stack_adj:
- it must be enough to store all of the listed registers
- it must be a multiple of 16 (bytes): ** for RV32 the allowed values are: 16, 32, 48, 64, 80, 96, 112 ** for RV64 the allowed values are: 16, 32, 48, 64, 80, 96, 112, 128, 144, 160
§Forms
Assembly: cm.pop reg_list, stack_adj
CMPOPRET = 176
Destroy function call stack frame and return to ra.
Destroy stack frame: load ra and 0 to 12 saved registers from the stack frame, deallocate the stack frame, return to ra.
This instruction pops (loads) the registers in reg_list from stack memory, and then adjusts the stack pointer by stack_adj and then return to ra.
Restrictions on stack_adj:
- it must be enough to store all of the listed registers
- it must be a multiple of 16 (bytes): ** for RV32 the allowed values are: 16, 32, 48, 64, 80, 96, 112 ** for RV64 the allowed values are: 16, 32, 48, 64, 80, 96, 112, 128, 144, 160
§Forms
Assembly: cm.popret reg_list, stack_adj
CMPOPRETZ = 177
Destroy function call stack frame, move zero to a0 and return to ra.
Destroy stack frame: load ra and 0 to 12 saved registers from the stack frame, deallocate the stack frame, move zero to a0, return to ra.
This instruction pops (loads) the registers in reg_list from stack memory, and then adjusts the stack pointer by stack_adj, move zero to a0 and then return to ra.
Restrictions on stack_adj:
- it must be enough to store all of the listed registers
- it must be a multiple of 16 (bytes): ** for RV32 the allowed values are: 16, 32, 48, 64, 80, 96, 112 ** for RV64 the allowed values are: 16, 32, 48, 64, 80, 96, 112, 128, 144, 160
§Forms
Assembly: cm.popretz reg_list, stack_adj
CMPUSH = 178
Create function call stack frame
Create stack frame: store ra and 0 to 12 saved registers to the stack frame, optionally allocate additional stack space.
This instruction pushes (stores) the registers in reg_list to the memory below the stack pointer,
and then creates the stack frame by decrementing the stack pointer by stack_adj.
Restrictions on stack_adj:
- it must be enough to store all of the listed registers
- it must be a multiple of 16 (bytes): ** for RV32 the allowed values are: 16, 32, 48, 64, 80, 96, 112 ** for RV64 the allowed values are: 16, 32, 48, 64, 80, 96, 112, 128, 144, 160
§Forms
Assembly: cm.push reg_list, -stack_adj
CPOP = 179
Count set bits
This instructions counts the number of 1’s (i.e., set bits) in the source register.
§.Software Hint [NOTE]
This operations is known as population count, popcount, sideways sum, bit summation, or Hamming weight.
§The GCC builtin function __builtin_popcount (unsigned int x) is
implemented by cpop on RV32 and by cpopw on RV64. The GCC builtin
function __builtin_popcountl (unsigned long x) for LP64 is
implemented by cpop on RV64.
§Forms
Assembly: cpop xd, xs1
CPOPW = 180
Count set bits in word
This instructions counts the number of 1’s (i.e., set bits) in the least-significant word of the source register.
§.Software Hint [NOTE]
This operations is known as population count, popcount, sideways sum, bit summation, or Hamming weight.
§The GCC builtin function __builtin_popcount (unsigned int x) is
implemented by cpop on RV32 and by cpopw on RV64. The GCC builtin
function __builtin_popcountl (unsigned long x) for LP64 is
implemented by cpop on RV64.
§Forms
Assembly: cpopw xd, xs1
CSRC = 181
CSRCI = 182
CSRR = 183
CSRRC = 184
CSRRCI = 185
CSRRS = 186
Atomic Read and Set Bits in CSR
Atomically read and set bits in a CSR.
Reads the value of the CSR, zero-extends the value to XLEN bits,
and writes it to integer register rd. The initial value in integer
register rs1 is treated as a bit mask that specifies bit positions
to be set in the CSR. Any bit that is high in rs1 will cause the
corresponding bit to be set in the CSR, if that CSR bit is writable.
Other bits in the CSR are not explicitly written.
§Forms
Assembly: csrrs xd, xs1, csr
CSRRSI = 187
CSRRW = 188
Atomic Read/Write CSR
Atomically swap values in the CSRs and integer registers.
Read the old value of the CSR, zero-extends the value to XLEN bits,
and then write it to integer register rd.
The initial value in rs1 is written to the CSR.
If rd=x0, then the instruction shall not read the CSR and shall not
cause any of the side effects that might occur on a CSR read.
§Forms
Assembly: csrrw xd, xs1, csr
CSRRWI = 189
Atomic Read/Write CSR Immediate
Atomically write CSR using a 5-bit immediate, and load the previous value into ‘rd’.
Read the old value of the CSR, zero-extends the value to XLEN bits,
and then write it to integer register rd.
The 5-bit uimm field is zero-extended and written to the CSR.
If rd=x0, then the instruction shall not read the CSR and shall not
cause any of the side effects that might occur on a CSR read.
§Forms
Assembly: csrrwi xd, zimm, csr
CSRS = 190
CSRSI = 191
CSRW = 192
CSRWI = 193
CTZ = 194
Count trailing zero bits
This instruction counts the number of 0’s before the first 1, starting at the least-significant bit (i.e., 0) and progressing to the most-significant bit (i.e., XLEN-1). Accordingly, if the input is 0, the output is XLEN, and if the least-significant bit of the input is a 1, the output is 0.
§Forms
Assembly: ctz xd, xs1
CTZW = 195
Count trailing zero bits in word
This instruction counts the number of 0’s before the first 1, starting at the least-significant bit (i.e., 0) and progressing to the most-significant bit of the least-significant word (i.e., 31). Accordingly, if the least-significant word is 0, the output is 32, and if the least-significant bit of the input is a 1, the output is 0.
§Forms
Assembly: ctzw xd, xs1
CZEROEQZ = 196
CZERONEZ = 197
DIV = 198
Signed division
Divide rs1 by rs2, and store the result in rd. The remainder is discarded.
Division by zero will put -1 into rd.
Division resulting in signed overflow (when most negative number is divided by -1) will put the most negative number into rd;
§Forms
Assembly: div xd, xs1, xs2
DIVU = 199
Unsigned division
Divide unsigned values in rs1 by rs2, and store the result in rd.
The remainder is discarded.
If the value in rs2 is zero, rd gets the largest unsigned value.
§Forms
Assembly: divu xd, xs1, xs2
DIVUW = 200
Unsigned 32-bit division
Divide the unsigned 32-bit values in rs1 and rs2, and store the sign-extended result in rd.
The remainder is discarded.
If the value in rs2 is zero, rd is written with all 1s.
§Forms
Assembly: divuw xd, xs1, xs2
DIVW = 201
Signed 32-bit division
Divide the lower 32-bits of register rs1 by the lower 32-bits of register rs2, and store the sign-extended result in rd.
The remainder is discarded.
Division by zero will put -1 into rd.
Division resulting in signed overflow (when most negative number is divided by -1) will put the most negative number into rd;
§Forms
Assembly: divw xd, xs1, xs2
DRET = 202
EBREAK = 203
Breakpoint exception
The EBREAK instruction is used by debuggers to cause control to be transferred back to a debugging environment. Unless overridden by an external debug environment, EBREAK raises a breakpoint exception and performs no other operation.
[NOTE]
As described in the C Standard Extension for Compressed Instructions, the c.ebreak
instruction performs the same operation as the EBREAK instruction.
EBREAK causes the receiving privilege mode’s epc register to be set to the address of
the EBREAK instruction itself, not the address of the following instruction.
As EBREAK causes a synchronous exception, it is not considered to retire,
and should not increment the minstret CSR.
§Forms
Assembly: ebreak ""
ECALL = 204
Environment call
The ECALL instruction is used to make a request to the supporting execution environment. When executed in U-mode, S-mode, or M-mode, it generates an environment-call-from-U-mode exception, environment-call-from-S-mode exception, or environment-call-from-M-mode exception, respectively, and performs no other operation.
[NOTE] ECALL generates a different exception for each originating privilege mode so that environment call exceptions can be selectively delegated. A typical use case for Unix-like operating systems is to delegate to S-mode the environment-call-from-U-mode exception but not the others.
ECALL causes the receiving privilege mode’s epc register to be set to the address of
the ECALL instruction itself, not the address of the following instruction.
As ECALL causes a synchronous exception, it is not considered to retire,
and should not increment the minstret CSR.
§Forms
Assembly: ecall ""
FABSD = 205
FABSH = 206
FABSQ = 207
FABSS = 208
FADDD = 209
FADDH = 210
FADDQ = 211
FADDS = 212
Single-precision floating-point addition
Do the single-precision floating-point addition of fs1 and fs2 and store the result in fd. rm is the dynamic Rounding Mode.
§Forms
Assembly: fadd.s fd, fs1, fs2, rm
FCLASSD = 213
FCLASSH = 214
FCLASSQ = 215
FCLASSS = 216
Single-precision floating-point classify.
The fclass.s instruction examines the value in floating-point register
fs1 and writes to integer register rd a 10-bit mask that indicates
the class of the floating-point number.
The format of the mask is described in the table below.
The corresponding bit in rd will be set if the property is true and
clear otherwise.
All other bits in rd are cleared.
Note that exactly one bit in rd will be set.
fclass.s does not set the floating-point exception flags.
.Format of result of fclass instruction.
[%autowidth,float=“center”,align=“center”,cols=“^,<”,options=“header”,]
|===
|rd bit |Meaning
|0 |rs1 is latexmath:[$-\infty$].
|1 |rs1 is a negative normal number.
|2 |rs1 is a negative subnormal number.
|3 |rs1 is latexmath:[$-0$].
|4 |rs1 is latexmath:[$+0$].
|5 |rs1 is a positive subnormal number.
|6 |rs1 is a positive normal number.
|7 |rs1 is latexmath:[$+\infty$].
|8 |rs1 is a signaling NaN.
|9 |rs1 is a quiet NaN.
|===
§Forms
Assembly: fclass.s xd, fs1
FCVTBF16S = 217
FCVTDH = 218
FCVTDL = 219
FCVTDLU = 220
FCVTDQ = 221
FCVTDS = 222
FCVTDW = 223
FCVTDWU = 224
FCVTHD = 225
FCVTHL = 226
FCVTHLU = 227
FCVTHQ = 228
FCVTHS = 229
Convert half-precision float to a single-precision float
Converts a half-precision number in floating-point register fs1 into a single-precision floating-point number in floating-point register fd.
fcvt.h.s rounds according to the rm field.
All floating-point conversion instructions set the Inexact exception flag if the rounded result differs from the operand value and the Invalid exception flag is not set.
§Forms
Assembly: fcvt.h.s fd, xs1
FCVTHW = 230
FCVTHWU = 231
FCVTLD = 232
FCVTLH = 233
FCVTLQ = 234
FCVTLS = 235
FCVTLUD = 236
FCVTLUH = 237
FCVTLUQ = 238
FCVTLUS = 239
FCVTQD = 240
FCVTQH = 241
FCVTQL = 242
FCVTQLU = 243
FCVTQS = 244
FCVTQW = 245
FCVTQWU = 246
FCVTSBF16 = 247
FCVTSD = 248
FCVTSH = 249
Convert single-precision float to a half-precision float
Converts a single-precision number in floating-point register fs1 into a half-precision floating-point number in floating-point register fd.
fcvt.s.h will never round, and so the ‘rm’ field is effectively ignored.
§Forms
Assembly: fcvt.s.h fd, xs1
FCVTSL = 250
FCVTSLU = 251
FCVTSQ = 252
FCVTSW = 253
Convert signed 32-bit integer to single-precision float
Converts a 32-bit signed integer in integer register rs1 into a floating-point number in floating-point register fd.
All floating-point to integer and integer to floating-point conversion instructions round
according to the rm field.
A floating-point register can be initialized to floating-point positive zero using
fcvt.s.w rd, x0, which will never set any exception flags.
All floating-point conversion instructions set the Inexact exception flag if the rounded result differs from the operand value and the Invalid exception flag is not set.
§Forms
Assembly: fcvt.s.w fd, xs1
FCVTSWU = 254
FCVTWD = 255
FCVTWH = 256
FCVTWQ = 257
FCVTWS = 258
Convert single-precision float to integer word to signed 32-bit integer.
Converts a floating-point number in floating-point register fs1 to a signed 32-bit integer indicates integer register rd.
For XLEN >32, fcvt.w.s sign-extends the 32-bit result to the destination register width.
If the rounded result is not representable as a 32-bit signed integer, it is clipped to the nearest value and the invalid flag is set.
The range of valid inputs and behavior for invalid inputs are:
[separator=“!”] !=== ! ! Value
h! Minimum valid input (after rounding) ! -2^31
h! Maximum valid input (after rounding) ! 2^31 - 1
h! Output for out-of-range negative input ! -2^31
h! Output for -∞ ! -2^31
h! Output for out-of-range positive input ! 2^31 - 1
h! Output for +∞ for NaN ! 2^31 - 1
!===
All floating-point to integer and integer to floating-point conversion instructions round
according to the rm field.
A floating-point register can be initialized to floating-point positive zero using
fcvt.s.w rd, x0, which will never set any exception flags.
All floating-point conversion instructions set the Inexact exception flag if the rounded result differs from the operand value and the Invalid exception flag is not set.
§Forms
Assembly: fcvt.w.s xd, fs1
FCVTWUD = 259
FCVTWUH = 260
FCVTWUQ = 261
FCVTWUS = 262
FCVTMODWD = 263
FDIVD = 264
FDIVH = 265
FDIVQ = 266
FDIVS = 267
FENCE = 268
Memory ordering fence
Orders memory operations.
The fence instruction is used to order device I/O and memory accesses as
viewed by other RISC-V harts and external devices or coprocessors. Any
combination of device input (I), device output (O), memory reads (R),
and memory writes (W) may be ordered with respect to any combination of
the same. Informally, no other RISC-V hart or external device can
observe any operation in the successor set following a fence before
any operation in the predecessor set preceding the fence.
The predecessor and successor fields have the same format to specify operation types:
[%autowidth]
|===
4+| pred 4+| succ
| 27 | 26 |25 | 24 | 23 | 22 | 21| 20 | PI | PO |PR | PW | SI | SO |SR | SW |===
[%autowidth,align=“center”,cols=“^1,^1,<3”,options=“header”]
.Fence mode encoding
|===
|fm field |Mnemonic |Meaning
|0000 |none |Normal Fence
|1000 |TSO |With FENCE RW,RW: exclude write-to-read ordering; otherwise: Reserved for future use.
2+|other |Reserved for future use.
|===
When the mode field fm is 0001 and both the predecessor and successor sets are ‘RW’,
then the instruction acts as a special-case fence.tso. fence.tso orders all load operations
in its predecessor set before all memory operations in its successor set, and all store operations
in its predecessor set before all store operations in its successor set. This leaves non-AMO store
operations in the ’fence.tso’s predecessor set unordered with non-AMO loads in its successor set.
When mode field fm is not 0001, or when mode field fm is 0001 but the pred and
succ fields are not both ‘RW’ (0x3), then the fence acts as a baseline fence (e.g., fm is
effectively 0000). This is unaffected by the FIOM bits, described below (implicit promotion does
not change how fence.tso is decoded).
The rs1 and rd fields are unused and ignored.
In modes other than M-mode, fence is further affected by menvcfg.FIOM,
senvcfg.FIOM<% if ext?(:H) %>, and/or henvcfg.FIOM<% end %>
as follows:
.Effective PR/PW/SR/SW in (H)S-mode
[%autowidth,cols=“,,,”,options=“header”,separator=“!”]
!===
! [.rotate]#menvcfg.FIOM# ! pred.PI +
pred.PO +
succ.SI +
succ.SO
! -> +
-> +
-> +
->
! effective PR +
effective PW +
effective SR +
effective SW
! 0 ! - ! ! from encoding ! 1 ! 0 ! ! from encoding ! 1 ! 1 ! ! 1 !===
.Effective PR/PW/SR/SW in U-mode
[%autowidth,options=“header”,separator=“!”,cols=“,,,,”]
!===
! [.rotate]#menvcfg.FIOM# ! [.rotate]#senvcfg.FIOM# ! pred.PI +
pred.PO +
succ.SI +
succ.SO
! -> +
-> +
-> +
->
! effective PR +
effective PW +
effective SR +
effective SW
! 0 ! 0 ! - ! ! from encoding ! 0 ! 1 ! 0 ! ! from encoding ! 0 ! 1 ! 1 ! ! 1 ! 1 ! - ! 0 ! ! from encoding ! 1 ! - ! 1 ! ! 1 !===
<%- if ext?(:H) -%>
.Effective PR/PW/SR/SW in VS-mode and VU-mode
[%autowidth,options=“header”,separator=“!”,cols=“,,,,”]
!===
! [.rotate]#menvcfg.FIOM# ! [.rotate]#henvcfg.FIOM# ! pred.PI +
pred.PO +
succ.SI +
succ.SO
! -> +
-> +
-> +
->
! effective PR +
effective PW +
effective SR +
effective SW
! 0 ! 0 ! - ! ! from encoding ! 0 ! 1 ! 0 ! ! from encoding ! 0 ! 1 ! 1 ! ! 1 ! 1 ! - ! 0 ! ! from encoding ! 1 ! - ! 1 ! ! 1 !=== <%- end -%>
§Forms
Assembly: fence "TODO"
FENCEI = 269
Instruction fence
The FENCE.I instruction is used to synchronize the instruction and data streams. RISC-V does not guarantee that stores to instruction memory will be made visible to instruction fetches on a RISC-V hart until that hart executes a FENCE.I instruction. A FENCE.I instruction ensures that a subsequent instruction fetch on a RISC-V hart will see any previous data stores already visible to the same RISC-V hart. FENCE.I does not ensure that other RISC-V harts’ instruction fetches will observe the local hart’s stores in a multiprocessor system. To make a store to instruction memory visible to all RISC-V harts, the writing hart also has to execute a data FENCE before requesting that all remote RISC-V harts execute a FENCE.I.
The unused fields in the FENCE.I instruction, imm[11:0], rs1, and rd, are reserved for finer-grain fences in future extensions. For forward compatibility, base implementations shall ignore these fields, and standard software shall zero these fields. (((FENCE.I, finer-grained))) (((FENCE.I, forward compatibility)))
§[NOTE]
§Because FENCE.I only orders stores with a hart’s own instruction fetches, application code should only rely upon FENCE.I if the application thread will not be migrated to a different hart. The EEI can provide mechanisms for efficient multiprocessor instruction-stream synchronization.
§Forms
Assembly: fence.i ""
FENCETSO = 270
FEQD = 271
FEQH = 272
FEQQ = 273
FEQS = 274
Single-precision floating-point equal
Writes 1 to rd if fs1 and fs2 are equal, and 0 otherwise.
If either operand is NaN, the result is 0 (not equal). If either operand is a signaling NaN, the invalid flag is set.
Positive zero is considered equal to negative zero.
§Forms
Assembly: feq.s xd, fs1, fs2
FLD = 275
FLED = 276
FLEH = 277
FLEQ = 278
FLES = 279
Single-precision floating-point less than or equal
Writes 1 to rd if fs1 is less than or equal to fs2, and 0 otherwise.
If either operand is NaN, the result is 0 (not equal). If either operand is a NaN (signaling or quiet), the invalid flag is set.
Positive zero and negative zero are considered equal.
§Forms
Assembly: fle.s xd, fs1, fs2
FLEQD = 280
FLEQH = 281
FLEQQ = 282
FLEQS = 283
FLH = 284
Half-precision floating-point load
The flh instruction loads a single-precision floating-point value from memory at address rs1 + imm into floating-point register rd.
flh does not modify the bits being transferred; in particular, the payloads of non-canonical NaNs are preserved.
flh is only guaranteed to execute atomically if the effective address is naturally aligned.
§Forms
Assembly: flh fd, imm(xs1)
FLID = 285
FLIH = 286
FLIQ = 287
FLIS = 288
FLQ = 289
FLTD = 290
FLTH = 291
FLTQ = 292
FLTS = 293
Single-precision floating-point less than
Writes 1 to rd if fs1 is less than fs2, and 0 otherwise.
If either operand is NaN, the result is 0 (not equal). If either operand is a NaN (signaling or quiet), the invalid flag is set.
§Forms
Assembly: flt.s xd, fs1, fs2
FLTQD = 294
FLTQH = 295
FLTQQ = 296
FLTQS = 297
FLW = 298
Single-precision floating-point load
The flw instruction loads a single-precision floating-point value from memory at address rs1 + imm into floating-point register fd.
flw does not modify the bits being transferred; in particular, the payloads of non-canonical NaNs are preserved.
§Forms
Assembly: flw fd, xs1, imm
FMADDD = 299
FMADDH = 300
FMADDQ = 301
FMADDS = 302
FMAXD = 303
FMAXH = 304
FMAXQ = 305
FMAXS = 306
FMAXMD = 307
FMAXMH = 308
FMAXMQ = 309
FMAXMS = 310
FMIND = 311
FMINH = 312
FMINQ = 313
FMINS = 314
FMINMD = 315
FMINMH = 316
FMINMQ = 317
FMINMS = 318
FMSUBD = 319
FMSUBH = 320
FMSUBQ = 321
FMSUBS = 322
FMULD = 323
FMULH = 324
FMULQ = 325
FMULS = 326
FMVD = 327
FMVDX = 328
FMVH = 329
FMVHX = 330
Half-precision floating-point move from integer
Moves the half-precision value encoded in IEEE 754-2008 standard encoding
from the lower 16 bits of integer register rs1 to the floating-point
register fd. The bits are not modified in the transfer, and in particular,
the payloads of non-canonical NaNs are preserved.
§Forms
Assembly: fmv.h.x fd, xs1
FMVQ = 331
FMVS = 332
FMVSX = 333
FMVWX = 334
Single-precision floating-point move from integer
Moves the single-precision value encoded in IEEE 754-2008 standard encoding
from the lower 32 bits of integer register rs1 to the floating-point
register fd. The bits are not modified in the transfer, and in particular,
the payloads of non-canonical NaNs are preserved.
§Forms
Assembly: fmv.w.x fd, xs1
FMVXD = 335
FMVXH = 336
Move half-precision value from floating-point to integer register
Moves the half-precision value in floating-point register rs1 represented in IEEE 754-2008 encoding to the lower 16 bits of integer register rd.
The bits are not modified in the transfer, and in particular, the payloads of non-canonical NaNs are preserved.
The highest XLEN-16 bits of the destination register are filled with copies of the floating-point number’s sign bit.
§Forms
Assembly: fmv.x.h rd, fs1
FMVXS = 337
FMVXW = 338
Move single-precision value from floating-point to integer register
Moves the single-precision value in floating-point register rs1 represented in IEEE 754-2008 encoding to the lower 32 bits of integer register rd. The bits are not modified in the transfer, and in particular, the payloads of non-canonical NaNs are preserved. For RV64, the higher 32 bits of the destination register are filled with copies of the floating-point number’s sign bit.
§Forms
Assembly: fmv.x.w xd, fs1
FMVHXD = 339
FMVHXQ = 340
FMVPDX = 341
FMVPQX = 342
FNEGD = 343
FNEGH = 344
FNEGQ = 345
FNEGS = 346
FNMADDD = 347
FNMADDH = 348
FNMADDQ = 349
FNMADDS = 350
FNMSUBD = 351
FNMSUBH = 352
FNMSUBQ = 353
FNMSUBS = 354
FRCSR = 355
FRFLAGS = 356
FROUNDD = 357
FROUNDH = 358
FROUNDQ = 359
FROUNDS = 360
FROUNDNXD = 361
FROUNDNXH = 362
FROUNDNXQ = 363
FROUNDNXS = 364
FRRM = 365
FSCSR = 366
FSD = 367
FSFLAGS = 368
FSFLAGSI = 369
FSGNJD = 370
FSGNJH = 371
FSGNJQ = 372
FSGNJS = 373
Single-precision sign inject
Writes fd with sign bit of fs2 and the exponent and mantissa of fs1.
Sign-injection instructions do not set floating-point exception flags, nor do they canonicalize NaNs.
§Forms
Assembly: fsgnj.s fd, fs1, fs2
FSGNJND = 374
FSGNJNH = 375
FSGNJNQ = 376
FSGNJNS = 377
Single-precision sign inject negate
Writes fd with the opposite of the sign bit of fs2 and the exponent and mantissa of fs1.
Sign-injection instructions do not set floating-point exception flags, nor do they canonicalize NaNs.
§Forms
Assembly: fsgnjn.s fd, fs1, fs2
FSGNJXD = 378
FSGNJXH = 379
FSGNJXQ = 380
FSGNJXS = 381
Single-precision sign inject exclusive or
Writes fd with the xor of the sign bits of fs2 and fs1 and the exponent and mantissa of fs1.
Sign-injection instructions do not set floating-point exception flags, nor do they canonicalize NaNs.
§Forms
Assembly: fsgnjx.s fd, fs1, fs2
FSH = 382
Half-precision floating-point store
The fsh instruction stores a half-precision floating-point value
from register rd to memory at address rs1 + imm.
fsh does not modify the bits being transferred; in particular, the payloads of non-canonical NaNs are preserved.
fsh ignores all but the lower 16 bits in rs2.
fsh is only guaranteed to execute atomically if the effective address is naturally aligned.
§Forms
Assembly: fsh fs2, imm(xs1)
FSQ = 383
FSQRTD = 384
FSQRTH = 385
FSQRTQ = 386
FSQRTS = 387
FSRM = 388
FSRMI = 389
FSUBD = 390
FSUBH = 391
FSUBQ = 392
FSUBS = 393
Single-precision floating-point subtraction
Do the single-precision floating-point subtraction of fs2 from fs1 and store the result in fd. rm is the dynamic Rounding Mode.
§Forms
Assembly: fsub.s fd, fs1, fs2, rm
FSW = 394
Single-precision floating-point store
The fsw instruction stores a single-precision floating-point value in fs2 to memory at address rs1 + imm.
fsw does not modify the bits being transferred; in particular, the payloads of non-canonical NaNs are preserved.
§Forms
Assembly: fsw fs2, xs1, imm
HFENCEGVMA = 395
HFENCEVVMA = 396
HINVALGVMA = 397
Invalidate cached address translations
hinval.gvma has the same semantics as sinval.vma except that it combines with
sfence.w.inval and sfence.inval.ir to replace hfence.gvma and uses VMID instead of ASID.
§Forms
Assembly: hinval.gvma xs1, xs2
HINVALVVMA = 398
Invalidate cached address translations
hinval.vvma has the same semantics as sinval.vma except that it combines with
sfence.w.inval and sfence.inval.ir to replace hfence.vvma.
§Forms
Assembly: hinval.vvma xs1, xs2
HLVB = 399
HLVBU = 400
HLVD = 401
HLVH = 402
HLVHU = 403
HLVW = 404
HLVWU = 405
HLVXHU = 406
HLVXWU = 407
HSVB = 408
HSVD = 409
HSVH = 410
HSVW = 411
J = 412
JAL = 413
Jump and link
Jump to a PC-relative offset and store the return address in rd.
§Forms
Assembly: jal xd, imm
JALPSEUDO = 414
JALR = 415
Jump and link register
Jump to an address formed by adding rs1 to a signed offset then clearing the least significant bit, and store the return address in rd.
§Forms
Assembly: jalr xd, imm(rs1)
JALRPSEUDO = 416
JR = 417
LB = 418
Load byte
Load 8 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
Sign extend the result.
§Forms
Assembly: lb xd, imm(rs1)
LBU = 419
Load byte unsigned
Load 8 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
Zero extend the result.
§Forms
Assembly: lbu xd, imm(rs1)
LD = 420
Load doubleword
Load 64 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
§Forms
Assembly: ld xd, imm(rs1)
LH = 421
Load halfword
Load 16 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
Sign extend the result.
§Forms
Assembly: lh xd, imm(rs1)
LHU = 422
Load halfword unsigned
Load 16 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
Zero extend the result.
§Forms
Assembly: lhu xd, imm(rs1)
LPAD = 423
LRD = 424
Load reserved doubleword
Loads a word from the address in rs1, places the value in rd, and registers a reservation set – a set of bytes that subsumes the bytes in the addressed word.
The address in rs1 must be 8-byte aligned.
If the address is not naturally aligned, a LoadAddressMisaligned exception or an
LoadAccessFault exception will be generated. The access-fault exception can be generated
for a memory access that would otherwise be able to complete except for the misalignment,
if the misaligned access should not be emulated.
An implementation can register an arbitrarily large reservation set on each LR, provided the reservation set includes all bytes of the addressed data word or doubleword. An SC can only pair with the most recent LR in program order. An SC may succeed only if no store from another hart to the reservation set can be observed to have occurred between the LR and the SC, and if there is no other SC between the LR and itself in program order. An SC may succeed only if no write from a device other than a hart to the bytes accessed by the LR instruction can be observed to have occurred between the LR and SC. Note this LR might have had a different effective address and data size, but reserved the SC’s address as part of the reservation set.
§[NOTE]
Following this model, in systems with memory translation, an SC is allowed to succeed if the earlier LR reserved the same location using an alias with a different virtual address, but is also allowed to fail if the virtual address is different.
§To accommodate legacy devices and buses, writes from devices other than RISC-V harts are only required to invalidate reservations when they overlap the bytes accessed by the LR. These writes are not required to invalidate the reservation when they access other bytes in the reservation set.
Software should not set the rl bit on an LR instruction unless the aq bit is also set. LR.rl and SC.aq instructions are not guaranteed to provide any stronger ordering than those with both bits clear, but may result in lower performance.
§Forms
Assembly: lr.d xd, xs1
LRW = 425
Load reserved word
Loads a word from the address in rs1, places the sign-extended value in rd, and registers a reservation set – a set of bytes that subsumes the bytes in the addressed word.
<%- if XLEN == 64 -%> The 32-bit load result is sign-extended to 64-bits. <%- end -%>
The address in rs1 must be naturally aligned to the size of the operand (i.e., eight-byte aligned for doublewords and four-byte aligned for words).
If the address is not naturally aligned, a LoadAddressMisaligned exception or an
LoadAccessFault exception will be generated. The access-fault exception can be generated
for a memory access that would otherwise be able to complete except for the misalignment,
if the misaligned access should not be emulated.
An implementation can register an arbitrarily large reservation set on each LR, provided the reservation set includes all bytes of the addressed data word or doubleword. An SC can only pair with the most recent LR in program order. An SC may succeed only if no store from another hart to the reservation set can be observed to have occurred between the LR and the SC, and if there is no other SC between the LR and itself in program order. An SC may succeed only if no write from a device other than a hart to the bytes accessed by the LR instruction can be observed to have occurred between the LR and SC. Note this LR might have had a different effective address and data size, but reserved the SC’s address as part of the reservation set.
§[NOTE]
Following this model, in systems with memory translation, an SC is allowed to succeed if the earlier LR reserved the same location using an alias with a different virtual address, but is also allowed to fail if the virtual address is different.
§To accommodate legacy devices and buses, writes from devices other than RISC-V harts are only required to invalidate reservations when they overlap the bytes accessed by the LR. These writes are not required to invalidate the reservation when they access other bytes in the reservation set.
Software should not set the rl bit on an LR instruction unless the aq bit is also set. LR.rl and SC.aq instructions are not guaranteed to provide any stronger ordering than those with both bits clear, but may result in lower performance.
§Forms
Assembly: lr.w xd, xs1
LUI = 426
LW = 427
Load word
Load 32 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
Sign extend the result.
§Forms
Assembly: lw xd, imm(rs1)
LWU = 428
Load word unsigned
Load 64 bits of data into register rd from an
address formed by adding rs1 to a signed offset.
Zero extend the result.
§Forms
Assembly: lwu xd, imm(rs1)
MAX = 429
Maximum
This instruction returns the larger of two signed integers.
.Software Hint
[NOTE]
Calculating the absolute value of a signed integer can be performed using the
following sequence: neg rD,rS followed by `max rD,rS,rD. When using this
common sequence, it is suggested that they are scheduled with no intervening
instructions so that implementations that are so optimized can fuse them
together.
§Forms
Assembly: max xd, xs1, xs2
MAXU = 430
Unsigned maximum
This instruction returns the larger of two unsigned integers.
§Forms
Assembly: maxu xd, xs1, xs2
MIN = 431
Minimum
This instruction returns the smaller of two signed integers.
§Forms
Assembly: min xd, xs1, xs2
MINU = 432
Unsigned minimum
This instruction returns the smaller of two unsigned integers.
§Forms
Assembly: minu xd, xs1, xs2
MNRET = 433
MOPR0 = 434
MOPR1 = 435
MOPR10 = 436
MOPR11 = 437
MOPR12 = 438
MOPR13 = 439
MOPR14 = 440
MOPR15 = 441
MOPR16 = 442
MOPR17 = 443
MOPR18 = 444
MOPR19 = 445
MOPR2 = 446
MOPR20 = 447
MOPR21 = 448
MOPR22 = 449
MOPR23 = 450
MOPR24 = 451
MOPR25 = 452
MOPR26 = 453
MOPR27 = 454
MOPR28 = 455
MOPR29 = 456
MOPR3 = 457
MOPR30 = 458
MOPR31 = 459
MOPR4 = 460
MOPR5 = 461
MOPR6 = 462
MOPR7 = 463
MOPR8 = 464
MOPR9 = 465
MOPRN = 466
RISC-V mop.r.n instruction.
§Forms
Assembly: mop.r.n mop_r_t_30, mop_r_t_27_26, mop_r_t_21_20, xd, xs1
MOPRR0 = 467
MOPRR1 = 468
MOPRR2 = 469
MOPRR3 = 470
MOPRR4 = 471
MOPRR5 = 472
MOPRR6 = 473
MOPRR7 = 474
MOPRRN = 475
MRET = 476
MUL = 477
Signed multiply
MUL performs an XLEN-bitxXLEN-bit multiplication of rs1 by rs2 and places the lower
XLEN bits in the destination register.
Any overflow is thrown away.
[NOTE] If both the high and low bits of the same product are required, then the recommended code sequence is: MULH[[S]U] rdh, rs1, rs2; MUL rdl, rs1, rs2 (source register specifiers must be in same order and rdh cannot be the same as rs1 or rs2). Microarchitectures can then fuse these into a single multiply operation instead of performing two separate multiplies.
§Forms
Assembly: mul xd, xs1, xs2
MULH = 478
Signed multiply high
Multiply the signed values in rs1 to rs2, and store the upper half of the result in rd. The lower half is thrown away.
If both the upper and lower halves are needed, it suggested to use the sequence:
§mulh rdh, rs1, rs2 mul rdl, rs1, rs2
Microarchitectures may look for that sequence and fuse the operations.
§Forms
Assembly: mulh xd, xs1, xs2
MULHSU = 479
Signed/unsigned multiply high
Multiply the signed value in rs1 by the unsigned value in rs2, and store the upper half of the result in rd. The lower half is thrown away.
If both the upper and lower halves are needed, it suggested to use the sequence:
§mulhsu rdh, rs1, rs2 mul rdl, rs1, rs2
Microarchitectures may look for that sequence and fuse the operations.
§Forms
Assembly: mulhsu xd, xs1, xs2
MULHU = 480
Unsigned multiply high
Multiply the unsigned values in rs1 to rs2, and store the upper half of the result in rd. The lower half is thrown away.
If both the upper and lower halves are needed, it suggested to use the sequence:
§mulhu rdh, rs1, rs2 mul rdl, rs1, rs2
Microarchitectures may look for that sequence and fuse the operations.
§Forms
Assembly: mulhu xd, xs1, xs2
MULW = 481
Signed 32-bit multiply
Multiplies the lower 32 bits of the source registers, placing the sign-extension of the lower 32 bits of the result into the destination register.
Any overflow is thrown away.
[NOTE] In RV64, MUL can be used to obtain the upper 32 bits of the 64-bit product, but signed arguments must be proper 32-bit signed values, whereas unsigned arguments must have their upper 32 bits clear. If the arguments are not known to be sign- or zero-extended, an alternative is to shift both arguments left by 32 bits, then use MULH[[S]U].
§Forms
Assembly: mulw xd, xs1, xs2
MV = 482
NEG = 483
NOP = 484
NTLALL = 485
NTLP1 = 486
NTLPALL = 487
NTLS1 = 488
OR = 489
ORCB = 490
Bitware OR-combine, byte granule
Combines the bits within each byte using bitwise logical OR. This sets the bits of each byte in the result rd to all zeros if no bit within the respective byte of rs is set, or to all ones if any bit within the respective byte of rs is set.
§Forms
Assembly: orc.b xd, xs1, xs2
ORI = 491
Or immediate
Or an immediate to the value in rs1, and store the result in rd
§Forms
Assembly: ori xd, xs1, imm
ORN = 492
OR with inverted operand
This instruction performs the bitwise logical OR operation between rs1 and the bitwise inversion of rs2.
§Forms
Assembly: orn xd, xs1, xs2
PACK = 493
PACKH = 494
PACKW = 495
PAUSE = 496
PREFETCHI = 497
PREFETCHR = 498
PREFETCHW = 499
RDCYCLE = 500
RDCYCLEH = 501
RDINSTRET = 502
RDINSTRETH = 503
RDTIME = 504
RDTIMEH = 505
REM = 506
Signed remainder
Calculate the remainder of signed division of rs1 by rs2, and store the result in rd.
If the value in register rs2 is zero, write the value in rs1 into rd;
If the result of the division overflows, write zero into rd;
§Forms
Assembly: rem xd, xs1, xs2
REMU = 507
Unsigned remainder
Calculate the remainder of unsigned division of rs1 by rs2, and store the result in rd.
§Forms
Assembly: remu xd, xs1, xs2
REMUW = 508
Unsigned 32-bit remainder
Calculate the remainder of unsigned division of the 32-bit values in rs1 by rs2, and store the sign-extended result in rd.
If the value in rs2 is zero, rd gets the sign-extended value in rs1.
§Forms
Assembly: remuw xd, xs1, xs2
REMW = 509
Signed 32-bit remainder
Calculate the remainder of signed division of the 32-bit values rs1 by rs2, and store the sign-extended result in rd.
If the value in register rs2 is zero, write the sign-extended 32-bit value in rs1 into rd;
If the result of the division overflows, write zero into rd;
§Forms
Assembly: remw xd, xs1, xs2
RET = 510
REV8 = 511
Byte-reverse register (RV64 encoding)
This instruction reverses the order of the bytes in rs1.
[NOTE] The rev8 mnemonic corresponds to different instruction encodings in RV32 and RV64.
[NOTE]
The byte-reverse operation is only available for the full register width. To emulate word-sized
and halfword-sized byte-reversal, perform a rev8 rd,rs followed by a srai rd,rd,K, where K
is XLEN-32 and XLEN-16, respectively.
§Forms
Assembly: rev8 xd, xs1
REV8RV32 = 512
Byte-reverse register (RV64 encoding)
This instruction reverses the order of the bytes in rs1.
[NOTE] The rev8 mnemonic corresponds to different instruction encodings in RV32 and RV64.
[NOTE]
The byte-reverse operation is only available for the full register width. To emulate word-sized
and halfword-sized byte-reversal, perform a rev8 rd,rs followed by a srai rd,rd,K, where K
is XLEN-32 and XLEN-16, respectively.
§Forms
Assembly: rev8.rv32 xd, xs1
ROL = 513
Rotate left (Register)
This instruction performs a rotate left of rs1 by the amount in least-significant log2(XLEN) bits of rs2.
§Forms
Assembly: rol xd, xs1, xs2
ROLW = 514
Rotate left word (Register)
This instruction performs a rotate left of the least-significant word of rs1 by the amount in least-significant 5 bits of rs2. The resulting word value is sign-extended by copying bit 31 to all of the more-significant bits.
§Forms
Assembly: rolw xd, xs1, xs2
ROR = 515
Rotate right (Register)
This instruction performs a rotate right of rs1 by the amount in least-significant log2(XLEN) bits of rs2.
§Forms
Assembly: ror xd, xs1, xs2
RORI = 516
Rotate right (Immediate)
This instruction performs a rotate right of rs1 by the amount in the least-significant log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: rori xd, xs1, shamt
RORIRV32 = 517
Rotate right (Immediate)
This instruction performs a rotate right of rs1 by the amount in the least-significant log2(XLEN) bits of shamt. For RV32, the encodings corresponding to shamt[5]=1 are reserved.
§Forms
Assembly: rori.rv32 xd, xs1, shamt
RORIW = 518
Rotate right word (Immediate)
This instruction performs a rotate right on the least-significant word of rs1 by the amount in the least-significant log2(XLEN) bits of shamt. The resulting word value is sign-extended by copying bit 31 to all of the more-significant bits.
§Forms
Assembly: roriw xd, xs1, shamt
RORW = 519
Rotate right word (Register)
This instruction performs a rotate right on the least-significant word of rs1 by the amount in least-significant 5 bits of rs2. The resultant word is sign-extended by copying bit 31 to all of the more-significant bits.
§Forms
Assembly: rorw xd, xs1, xs2
SB = 520
Store byte
Store 8 bits of data from register rs2 to an
address formed by adding rs1 to a signed offset.
§Forms
Assembly: sb xs2, imm(xs1)
SBREAK = 521
SCD = 522
Store conditional doubleword
sc.d conditionally writes a doubleword in rs2 to the address in rs1:
the sc.d succeeds only if the reservation is still valid and the
reservation set contains the bytes being written. If the sc.d succeeds,
the instruction writes the doubleword in rs2 to memory, and it writes zero to rd.
If the sc.d fails, the instruction does not write to memory, and it writes a
nonzero value to rd. For the purposes of memory protection, a failed sc.d
may be treated like a store. Regardless of success or failure, executing an
sc.d instruction invalidates any reservation held by this hart.
The failure code with value 1 encodes an unspecified failure. Other failure codes are reserved at this time. Portable software should only assume the failure code will be non-zero.
The address held in rs1 must be naturally aligned to the size of the operand (i.e., eight-byte aligned). If the address is not naturally aligned, an address-misaligned exception or an access-fault exception will be generated. The access-fault exception can be generated for a memory access that would otherwise be able to complete except for the misalignment, if the misaligned access should not be emulated.
§[NOTE]
Emulating misaligned LR/SC sequences is impractical in most systems.
§Misaligned LR/SC sequences also raise the possibility of accessing multiple reservation sets at once, which present definitions do not provide for.
An implementation can register an arbitrarily large reservation set on each LR, provided the reservation set includes all bytes of the addressed data word or doubleword. An SC can only pair with the most recent LR in program order. An SC may succeed only if no store from another hart to the reservation set can be observed to have occurred between the LR and the SC, and if there is no other SC between the LR and itself in program order. An SC may succeed only if no write from a device other than a hart to the bytes accessed by the LR instruction can be observed to have occurred between the LR and SC. Note this LR might have had a different effective address and data size, but reserved the SC’s address as part of the reservation set.
§[NOTE]
Following this model, in systems with memory translation, an SC is allowed to succeed if the earlier LR reserved the same location using an alias with a different virtual address, but is also allowed to fail if the virtual address is different.
§To accommodate legacy devices and buses, writes from devices other than RISC-V harts are only required to invalidate reservations when they overlap the bytes accessed by the LR. These writes are not required to invalidate the reservation when they access other bytes in the reservation set.
The SC must fail if the address is not within the reservation set of the most recent LR in program order. The SC must fail if a store to the reservation set from another hart can be observed to occur between the LR and SC. The SC must fail if a write from some other device to the bytes accessed by the LR can be observed to occur between the LR and SC. (If such a device writes the reservation set but does not write the bytes accessed by the LR, the SC may or may not fail.) An SC must fail if there is another SC (to any address) between the LR and the SC in program order. The precise statement of the atomicity requirements for successful LR/SC sequences is defined by the Atomicity Axiom of the memory model.
§[NOTE]
The platform should provide a means to determine the size and shape of the reservation set.
A platform specification may constrain the size and shape of the reservation set.
A store-conditional instruction to a scratch word of memory should be used to forcibly invalidate any existing load reservation:
- during a preemptive context switch, and
- if necessary when changing virtual to physical address mappings, such as when migrating pages that might contain an active reservation.
§The invalidation of a hart’s reservation when it executes an LR or SC imply that a hart can only hold one reservation at a time, and that an SC can only pair with the most recent LR, and LR with the next following SC, in program order. This is a restriction to the Atomicity Axiom in Section 18.1 that ensures software runs correctly on expected common implementations that operate in this manner.
An SC instruction can never be observed by another RISC-V hart before the LR instruction that established the reservation.
§[NOTE]
The LR/SC sequence can be given acquire semantics by setting the aq bit on the LR instruction. The LR/SC sequence can be given release semantics by by setting the rl bit on the SC instruction. Assuming suitable mappings for other atomic operations, setting the aq bit on the LR instruction, and setting the rl bit on the SC instruction makes the LR/SC sequence sequentially consistent in the C++ memory_order_seq_cst sense. Such a sequence does not act as a fence for ordering ordinary load and store instructions before and after the sequence. Specific instruction mappings for other C++ atomic operations, or stronger notions of “sequential consistency”, may require both bits to be set on either or both of the LR or SC instruction.
§If neither bit is set on either LR or SC, the LR/SC sequence can be observed to occur before or after surrounding memory operations from the same RISC-V hart. This can be appropriate when the LR/SC sequence is used to implement a parallel reduction operation.
Software should not set the rl bit on an LR instruction unless the aq bit is also set. LR.rl and SC.aq instructions are not guaranteed to provide any stronger ordering than those with both bits clear, but may result in lower performance.
§Forms
Assembly: sc.d xd, xs2, xs1
SCW = 523
Store conditional word
sc.w conditionally writes a word in rs2 to the address in rs1:
the sc.w succeeds only if the reservation is still valid and the
reservation set contains the bytes being written. If the sc.w succeeds,
the instruction writes the word in rs2 to memory, and it writes zero to rd.
If the sc.w fails, the instruction does not write to memory, and it writes a
nonzero value to rd. For the purposes of memory protection, a failed sc.w
may be treated like a store. Regardless of success or failure, executing an
sc.w instruction invalidates any reservation held by this hart.
<%- if XLEN == 64 -%>
[NOTE]
If a value other than 0 or 1 is defined as a result for sc.w, the value will before
sign-extended into rd.
<%- end -%>
The failure code with value 1 encodes an unspecified failure. Other failure codes are reserved at this time. Portable software should only assume the failure code will be non-zero.
The address held in rs1 must be naturally aligned to the size of the operand (i.e., eight-byte aligned for doublewords and four-byte aligned for words). If the address is not naturally aligned, an address-misaligned exception or an access-fault exception will be generated. The access-fault exception can be generated for a memory access that would otherwise be able to complete except for the misalignment, if the misaligned access should not be emulated.
§[NOTE]
Emulating misaligned LR/SC sequences is impractical in most systems.
§Misaligned LR/SC sequences also raise the possibility of accessing multiple reservation sets at once, which present definitions do not provide for.
An implementation can register an arbitrarily large reservation set on each LR, provided the reservation set includes all bytes of the addressed data word or doubleword. An SC can only pair with the most recent LR in program order. An SC may succeed only if no store from another hart to the reservation set can be observed to have occurred between the LR and the SC, and if there is no other SC between the LR and itself in program order. An SC may succeed only if no write from a device other than a hart to the bytes accessed by the LR instruction can be observed to have occurred between the LR and SC. Note this LR might have had a different effective address and data size, but reserved the SC’s address as part of the reservation set.
§[NOTE]
Following this model, in systems with memory translation, an SC is allowed to succeed if the earlier LR reserved the same location using an alias with a different virtual address, but is also allowed to fail if the virtual address is different.
§To accommodate legacy devices and buses, writes from devices other than RISC-V harts are only required to invalidate reservations when they overlap the bytes accessed by the LR. These writes are not required to invalidate the reservation when they access other bytes in the reservation set.
The SC must fail if the address is not within the reservation set of the most recent LR in program order. The SC must fail if a store to the reservation set from another hart can be observed to occur between the LR and SC. The SC must fail if a write from some other device to the bytes accessed by the LR can be observed to occur between the LR and SC. (If such a device writes the reservation set but does not write the bytes accessed by the LR, the SC may or may not fail.) An SC must fail if there is another SC (to any address) between the LR and the SC in program order. The precise statement of the atomicity requirements for successful LR/SC sequences is defined by the Atomicity Axiom of the memory model.
§[NOTE]
The platform should provide a means to determine the size and shape of the reservation set.
A platform specification may constrain the size and shape of the reservation set.
A store-conditional instruction to a scratch word of memory should be used to forcibly invalidate any existing load reservation:
- during a preemptive context switch, and
- if necessary when changing virtual to physical address mappings, such as when migrating pages that might contain an active reservation.
§The invalidation of a hart’s reservation when it executes an LR or SC imply that a hart can only hold one reservation at a time, and that an SC can only pair with the most recent LR, and LR with the next following SC, in program order. This is a restriction to the Atomicity Axiom in Section 18.1 that ensures software runs correctly on expected common implementations that operate in this manner.
An SC instruction can never be observed by another RISC-V hart before the LR instruction that established the reservation.
§[NOTE]
The LR/SC sequence can be given acquire semantics by setting the aq bit on the LR instruction. The LR/SC sequence can be given release semantics by by setting the rl bit on the SC instruction. Assuming suitable mappings for other atomic operations, setting the aq bit on the LR instruction, and setting the rl bit on the SC instruction makes the LR/SC sequence sequentially consistent in the C++ memory_order_seq_cst sense. Such a sequence does not act as a fence for ordering ordinary load and store instructions before and after the sequence. Specific instruction mappings for other C++ atomic operations, or stronger notions of “sequential consistency”, may require both bits to be set on either or both of the LR or SC instruction.
§If neither bit is set on either LR or SC, the LR/SC sequence can be observed to occur before or after surrounding memory operations from the same RISC-V hart. This can be appropriate when the LR/SC sequence is used to implement a parallel reduction operation.
Software should not set the rl bit on an LR instruction unless the aq bit is also set. LR.rl and SC.aq instructions are not guaranteed to provide any stronger ordering than those with both bits clear, but may result in lower performance.
§Forms
Assembly: sc.w xd, xs2, xs1
SCALL = 524
SCTRCLR = 525
SD = 526
Store doubleword
Store 64 bits of data from register rs2 to an
address formed by adding rs1 to a signed offset.
§Forms
Assembly: sd xs2, imm(xs1)
SEQZ = 527
SEXTB = 528
Sign-extend byte
This instruction sign-extends the least-significant byte in the source to XLEN by copying the most-significant bit in the byte (i.e., bit 7) to all of the more-significant bits.
§Forms
Assembly: sext.b xd, xs1
SEXTH = 529
Sign-extend halfword
This instruction sign-extends the least-significant halfword in the source to XLEN by copying the most-significant bit in the halfword (i.e., bit 15) to all of the more-significant bits.
§Forms
Assembly: sext.h xd, xs1
SEXTW = 530
SFENCEINVALIR = 531
Order implicit page table reads after invalidation
The sfence.inval.ir instruction guarantees that any previous sinval.vma
instructions executed by the current hart are ordered before subsequent implicit references by
that hart to the memory-management data structures.
§Forms
Assembly: sfence.inval.ir ""
SFENCEVMA = 532
Supervisor memory-management fence
The supervisor memory-management fence instruction SFENCE.VMA is used to
synchronize updates to in-memory memory-management data structures with
current execution. Instruction execution causes implicit reads and
writes to these data structures; however, these implicit references are
ordinarily not ordered with respect to explicit loads and stores.
Executing an SFENCE.VMA instruction guarantees that any previous stores
already visible to the current RISC-V hart are ordered before certain
implicit references by subsequent instructions in that hart to the
memory-management data structures. The specific set of operations
ordered by SFENCE.VMA is determined by rs1 and rs2, as described
below. SFENCE.VMA is also used to invalidate entries in the
address-translation cache associated with a hart (see <<sv32algorithm>>). Further details on the behavior of this instruction are described in <<virt-control>> and <<pmp-vmem>>.
§[NOTE]
§The SFENCE.VMA is used to flush any local hardware caches related to address translation. It is specified as a fence rather than a TLB flush to provide cleaner semantics with respect to which instructions are affected by the flush operation and to support a wider variety of dynamic caching structures and memory-management schemes. SFENCE.VMA is also used by higher privilege levels to synchronize page table writes and the address translation hardware.
SFENCE.VMA orders only the local hart’s implicit references to the memory-management data structures.
§[NOTE]
§Consequently, other harts must be notified separately when the memory-management data structures have been modified. One approach is to use 1) a local data fence to ensure local writes are visible globally, then 2) an interprocessor interrupt to the other thread, then 3) a local SFENCE.VMA in the interrupt handler of the remote thread, and finally 4) signal back to originating thread that operation is complete. This is, of course, the RISC-V analog to a TLB shootdown.
For the common case that the translation data structures have only been modified for a single address mapping (i.e., one page or superpage), rs1 can specify a virtual address within that mapping to effect a translation fence for that mapping only. Furthermore, for the common case that the translation data structures have only been modified for a single address-space identifier, rs2 can specify the address space. The behavior of SFENCE.VMA depends on rs1 and rs2 as follows:
- If rs1=
x0and rs2=x0, the fence orders all reads and writes made to any level of the page tables, for all address spaces. The fence also invalidates all address-translation cache entries, for all address spaces. - If rs1=
x0and rs2≠x0, the fence orders all reads and writes made to any level of the page tables, but only for the address space identified by integer register rs2. Accesses to global mappings (see <<translation>>) are not ordered. The fence also invalidates all address-translation cache entries matching the address space identified by integer register rs2, except for entries containing global mappings. - If rs1≠
x0and rs2=x0, the fence orders only reads and writes made to leaf page table entries corresponding to the virtual address in rs1, for all address spaces. The fence also invalidates all address-translation cache entries that contain leaf page table entries corresponding to the virtual address in rs1, for all address spaces. - If rs1≠
x0and rs2≠x0, the fence orders only reads and writes made to leaf page table entries corresponding to the virtual address in rs1, for the address space identified by integer register rs2. Accesses to global mappings are not ordered. The fence also invalidates all address-translation cache entries that contain leaf page table entries corresponding to the virtual address in rs1 and that match the address space identified by integer register rs2, except for entries containing global mappings.
If the value held in rs1 is not a valid virtual address, then the SFENCE.VMA instruction has no effect. No exception is raised in this case.
When rs2≠x0, bits SXLEN-1:ASIDMAX of the value held
in rs2 are reserved for future standard use. Until their use is
defined by a standard extension, they should be zeroed by software and
ignored by current implementations. Furthermore, if
ASIDLEN<ASIDMAX, the implementation shall ignore bits
ASIDMAX-1:ASIDLEN of the value held in rs2.
§[NOTE]
§It is always legal to over-fence, e.g., by fencing only based on a
subset of the bits in rs1 and/or rs2, and/or by simply treating all
SFENCE.VMA instructions as having rs1=x0 and/or rs2=x0. For
example, simpler implementations can ignore the virtual address in rs1
and the ASID value in rs2 and always perform a global fence. The
choice not to raise an exception when an invalid virtual address is held
in rs1 facilitates this type of simplification.
An implicit read of the memory-management data structures may return any translation for an address that was valid at any time since the most recent SFENCE.VMA that subsumes that address. The ordering implied by SFENCE.VMA does not place implicit reads and writes to the memory-management data structures into the global memory order in a way that interacts cleanly with the standard RVWMO ordering rules. In particular, even though an SFENCE.VMA orders prior explicit accesses before subsequent implicit accesses, and those implicit accesses are ordered before their associated explicit accesses, SFENCE.VMA does not necessarily place prior explicit accesses before subsequent explicit accesses in the global memory order. These implicit loads also need not otherwise obey normal program order semantics with respect to prior loads or stores to the same address.
§[NOTE]
A consequence of this specification is that an implementation may use any translation for an address that was valid at any time since the most recent SFENCE.VMA that subsumes that address. In particular, if a leaf PTE is modified but a subsuming SFENCE.VMA is not executed, either the old translation or the new translation will be used, but the choice is unpredictable. The behavior is otherwise well-defined.
In a conventional TLB design, it is possible for multiple entries to
match a single address if, for example, a page is upgraded to a
superpage without first clearing the original non-leaf PTE’s valid bit
and executing an SFENCE.VMA with rs1=x0. In this case, a similar
remark applies: it is unpredictable whether the old non-leaf PTE or the
new leaf PTE is used, but the behavior is otherwise well defined.
Another consequence of this specification is that it is generally unsafe to update a PTE using a set of stores of a width less than the width of the PTE, as it is legal for the implementation to read the PTE at any time, including when only some of the partial stores have taken effect.
§This specification permits the caching of PTEs whose V (Valid) bit is clear. Operating systems must be written to cope with this possibility, but implementers are reminded that eagerly caching invalid PTEs will reduce performance by causing additional page faults.
Implementations must only perform implicit reads of the translation data
structures pointed to by the current contents of the satp register or
a subsequent valid (V=1) translation data structure entry, and must only
raise exceptions for implicit accesses that are generated as a result of
instruction execution, not those that are performed speculatively.
Changes to the sstatus fields SUM and MXR take effect immediately,
without the need to execute an SFENCE.VMA instruction. Changing
satp.MODE from Bare to other modes and vice versa also takes effect
immediately, without the need to execute an SFENCE.VMA instruction.
Likewise, changes to satp.ASID take effect immediately.
§[TIP]
The following common situations typically require executing an SFENCE.VMA instruction:
- When software recycles an ASID (i.e., reassociates it with a different
page table), it should first change
satpto point to the new page table using the recycled ASID, then execute SFENCE.VMA with rs1=x0and rs2 set to the recycled ASID. Alternatively, software can execute the same SFENCE.VMA instruction while a different ASID is loaded intosatp, provided the next timesatpis loaded with the recycled ASID, it is simultaneously loaded with the new page table. - If the implementation does not provide ASIDs, or software chooses to
always use ASID 0, then after every
satpwrite, software should execute SFENCE.VMA with rs1=x0. In the common case that no global translations have been modified, rs2 should be set to a register other thanx0but which contains the value zero, so that global translations are not flushed. - If software modifies a non-leaf PTE, it should execute SFENCE.VMA with
rs1=
x0. If any PTE along the traversal path had its G bit set, rs2 must bex0; otherwise, rs2 should be set to the ASID for which the translation is being modified. - If software modifies a leaf PTE, it should execute SFENCE.VMA with
rs1 set to a virtual address within the page. If any PTE along the
traversal path had its G bit set, rs2 must be
x0; otherwise, rs2 should be set to the ASID for which the translation is being modified. - For the special cases of increasing the permissions on a leaf PTE and changing an invalid PTE to a valid leaf, software may choose to execute the SFENCE.VMA lazily. After modifying the PTE but before executing SFENCE.VMA, either the new or old permissions will be used. In the latter case, a page-fault exception might occur, at which point software should execute SFENCE.VMA in accordance with the previous bullet point. ====
If a hart employs an address-translation cache, that cache must appear to be private to that hart. In particular, the meaning of an ASID is local to a hart; software may choose to use the same ASID to refer to different address spaces on different harts.
§[NOTE]
§A future extension could redefine ASIDs to be global across the SEE, enabling such options as shared translation caches and hardware support for broadcast TLB shootdown. However, as OSes have evolved to significantly reduce the scope of TLB shootdowns using novel ASID-management techniques, we expect the local-ASID scheme to remain attractive for its simplicity and possibly better scalability.
For implementations that make satp.MODE read-only zero (always Bare),
attempts to execute an SFENCE.VMA instruction might raise an
illegal-instruction exception.
§Forms
Assembly: sfence.vma xs1, xs2
SFENCEWINVAL = 533
Order writes before sfence
The sfence.w.inval instruction guarantees that any previous stores already visible to the
current RISC-V hart are ordered before subsequent sinval.vma instructions executed by the
same hart.
§Forms
Assembly: sfence.w.inval ""
SGTZ = 534
SH = 535
Store halfword
Store 16 bits of data from register rs2 to an
address formed by adding rs1 to a signed offset.
§Forms
Assembly: sh xs2, imm(xs1)
SH1ADD = 536
Shift left by 1 and add
This instruction shifts rs1 to the left by 1 bit and adds it to rs2.
§Forms
Assembly: sh1add xd, xs1, xs2
SH1ADDUW = 537
Shift unsigned word left by 1 and add
This instruction performs an XLEN-wide addition of two addends. The first addend is rs2. The second addend is the unsigned value formed by extracting the least-significant word of rs1 and shifting it left by 1 place.
§Forms
Assembly: sh1add.uw xd, xs1, xs2
SH2ADD = 538
Shift left by 2 and add
This instruction shifts rs1 to the left by 2 places and adds it to rs2.
§Forms
Assembly: sh2add xd, xs1, xs2
SH2ADDUW = 539
Shift unsigned word left by 2 and add
This instruction performs an XLEN-wide addition of two addends. The first addend is rs2. The second addend is the unsigned value formed by extracting the least-significant word of rs1 and shifting it left by 2 places.
§Forms
Assembly: sh2add.uw xd, xs1, xs2
SH3ADD = 540
Shift left by 3 and add
This instruction shifts rs1 to the left by 3 places and adds it to rs2.
§Forms
Assembly: sh3add xd, xs1, xs2
SH3ADDUW = 541
Shift unsigned word left by 3 and add
This instruction performs an XLEN-wide addition of two addends. The first addend is rs2. The second addend is the unsigned value formed by extracting the least-significant word of rs1 and shifting it left by 3 places.
§Forms
Assembly: sh3add.uw xd, xs1, xs2
SHA256SIG0 = 542
SHA256SIG1 = 543
SHA256SUM0 = 544
SHA256SUM1 = 545
SHA512SIG0 = 546
SHA512SIG0H = 547
SHA512SIG0L = 548
SHA512SIG1 = 549
SHA512SIG1H = 550
SHA512SIG1L = 551
SHA512SUM0 = 552
SHA512SUM0R = 553
SHA512SUM1 = 554
SHA512SUM1R = 555
SINVALVMA = 556
SLL = 557
Shift left logical
Shift the value in rs1 left by the value in the lower 6 bits of rs2, and store the result in rd.
§Forms
Assembly: sll xd, xs1, xs2
SLLI = 558
Shift left logical immediate
Shift the value in rs1 left by shamt, and store the result in rd
§Forms
Assembly: slli xd, xs1, shamt
SLLIRV32 = 559
Shift left logical immediate
Shift the value in rs1 left by shamt, and store the result in rd
§Forms
Assembly: slli.rv32 xd, xs1, shamt
SLLIUW = 560
Shift left unsigned word (Immediate)
This instruction takes the least-significant word of rs1, zero-extends it, and shifts it left by the immediate.
[NOTE]
This instruction is the same as slli with zext.w performed on rs1 before shifting.
§Forms
Assembly: slli.uw xd, xs1, shamt
SLLIW = 561
Shift left logical immediate word
Shift the 32-bit value in rs1 left by shamt, and store the sign-extended result in rd
§Forms
Assembly: slliw xd, xs1, shamt
SLLW = 562
Shift left logical word
Shift the 32-bit value in rs1 left by the value in the lower 5 bits of rs2, and store the sign-extended result in rd.
§Forms
Assembly: sllw xd, xs1, xs2
SLT = 563
Set on less than
Places the value 1 in register rd if register rs1 is less than the value in register rs2, where
both sources are treated as signed numbers, else 0 is written to rd.
§Forms
Assembly: slt xd, xs1, rs2
SLTI = 564
Set on less than immediate
Places the value 1 in register rd if register rs1 is less than the sign-extended immediate
when both are treated as signed numbers, else 0 is written to rd.
§Forms
Assembly: slti xd, xs1, imm
SLTIU = 565
Set on less than immediate unsigned
Places the value 1 in register rd if register rs1 is less than the sign-extended immediate
when both are treated as unsigned numbers (i.e., the immediate is first sign-extended to
XLEN bits then treated as an unsigned number), else 0 is written to rd.
NOTE: sltiu rd, rs1, 1 sets rd to 1 if rs1 equals zero, otherwise sets rd to 0
(assembler pseudoinstruction SEQZ rd, rs).
§Forms
Assembly: sltiu xd, xs1, imm
SLTU = 566
Set on less than unsigned
Places the value 1 in register rd if register rs1 is less than the value in register rs2, where
both sources are treated as unsigned numbers, else 0 is written to rd.
§Forms
Assembly: sltu xd, xs1, xs2
SLTZ = 567
SM3P0 = 568
SM3P1 = 569
SM4ED = 570
SM4KS = 571
SNEZ = 572
SRA = 573
Shift right arithmetic
Arithmetic shift the value in rs1 right by the value in the lower 5 bits of rs2, and store the result in rd.
§Forms
Assembly: sra xd, xs1, xs2
SRAI = 574
Shift right arithmetic immediate
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in rs1 right by shamt, and store the result in rd.
§Forms
Assembly: srai xd, xs1, shamt
SRAIRV32 = 575
Shift right arithmetic immediate
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the value in rs1 right by shamt, and store the result in rd.
§Forms
Assembly: srai.rv32 xd, xs1, shamt
SRAIW = 576
Shift right arithmetic immediate word
Arithmetic shift (the original sign bit is copied into the vacated upper bits) the 32-bit value in rs1 right by shamt, and store the sign-extended result in rd.
§Forms
Assembly: sraiw xd, xs1, shamt
SRAW = 577
Shift right arithmetic word
Arithmetic shift the 32-bit value in rs1 right by the value in the lower 5 bits of rs2, and store the sign-extended result in rd.
§Forms
Assembly: sraw xd, xs1, xs2
SRET = 578
Supervisor Exception Return
Returns from an exception.
When sret is allowed to execute, its behavior depends on whether or not the current privilege
mode is virtualized.
When the current privilege mode is (H)S-mode or M-mode
sret sets hstatus.HPV = 0, mstatus.SPP = 0,
mstatus.SIE = mstatus.SPIE, and mstatus.SPIE = 1,
changes the privilege mode according to the table below,
and then jumps to the address in sepc.
.Next privilege mode following an sret in (H)S-mode or M-mode
[%autowidth]
|===
| [.rotate]#mstatus.SPP# | [.rotate]#hstatus.SPV# .>| Mode after sret
| 0 | 0 | U-mode | 0 | 1 | VU-mode | 1 | 0 | (H)S-mode | 1 | 1 | VS-mode |===
When the current privilege mode is VS-mode
sret sets
vsstatus.SPP = 0, vsstatus.SIE = vstatus.SPIE, and vsstatus.SPIE = 1,
changes the privilege mode according to the table below,
and then jumps to the address in vsepc.
.Next privilege mode following an sret in (H)S-mode or M-mode
[%autowidth]
|===
| [.rotate]#vsstatus.SPP# .>| Mode after sret
| 0 | VU-mode | 1 | VS-mode |===
§Forms
Assembly: sret ""
SRL = 579
Shift right logical
Logical shift the value in rs1 right by the value in the lower bits of rs2, and store the result in rd.
§Forms
Assembly: srl xd, xs1, xs2
SRLI = 580
Shift right logical immediate
Shift the value in rs1 right by shamt, and store the result in rd
§Forms
Assembly: srli xd, xs1, shamt
SRLIRV32 = 581
Shift right logical immediate
Shift the value in rs1 right by shamt, and store the result in rd
§Forms
Assembly: srli.rv32 xd, xs1, shamt
SRLIW = 582
Shift right logical immediate word
Shift the 32-bit value in rs1 right by shamt, and store the sign-extended result in rd
§Forms
Assembly: srliw xd, xs1, shamt
SRLW = 583
Shift right logical word
Logical shift the 32-bit value in rs1 right by the value in the lower 5 bits of rs2, and store the sign-extended result in rd.
§Forms
Assembly: srlw xd, xs1, xs2
SSAMOSWAPD = 584
SSAMOSWAPW = 585
SSPOPCHKX1 = 586
SSPOPCHKX5 = 587
SSPUSHX1 = 588
SSPUSHX5 = 589
SSRDP = 590
SUB = 591
Subtract
Subtract the value in rs2 from rs1, and store the result in rd
§Forms
Assembly: sub xd, xs1, xs2
SUBW = 592
Subtract word
Subtract the 32-bit values in rs2 from rs1, and store the sign-extended result in rd
§Forms
Assembly: subw xd, xs1, xs2
SW = 593
Store word
Store 32 bits of data from register rs2 to an
address formed by adding rs1 to a signed offset.
§Forms
Assembly: sw xs2, imm(xs1)
UNZIP = 594
Bit deinterleave
This instruction gathers bits from the high and low halves of the source word into odd/even bit positions in the destination word. It is the inverse of the zip instruction. This instruction is available only on RV32.
§Forms
Assembly: unzip xd, xs1
VAADDVV = 595
VAADDVX = 596
VAADDUVV = 597
VAADDUVX = 598
VADCVIM = 599
VADCVVM = 600
VADCVXM = 601
VADDVI = 602
VADDVV = 603
VADDVX = 604
VAESDFVS = 605
VAESDFVV = 606
VAESDMVS = 607
VAESDMVV = 608
VAESEFVS = 609
VAESEFVV = 610
VAESEMVS = 611
VAESEMVV = 612
VAESKF1VI = 613
VAESKF2VI = 614
VAESZVS = 615
VANDVI = 616
VANDVV = 617
VANDVX = 618
VANDNVV = 619
VANDNVX = 620
VASUBVV = 621
VASUBVX = 622
VASUBUVV = 623
VASUBUVX = 624
VBREV8V = 625
VBREVV = 626
VCLMULVV = 627
VCLMULVX = 628
VCLMULHVV = 629
VCLMULHVX = 630
VCLZV = 631
VCOMPRESSVM = 632
VCPOPM = 633
VCPOPV = 634
VCTZV = 635
VDIVVV = 636
VDIVVX = 637
VDIVUVV = 638
VDIVUVX = 639
VFADDVF = 640
VFADDVV = 641
VFCLASSV = 642
VFCVTFXV = 643
VFCVTFXUV = 644
VFCVTRTZXFV = 645
VFCVTRTZXUFV = 646
VFCVTXFV = 647
VFCVTXUFV = 648
VFDIVVF = 649
VFDIVVV = 650
VFIRSTM = 651
VFMACCVF = 652
VFMACCVV = 653
VFMADDVF = 654
VFMADDVV = 655
VFMAXVF = 656
VFMAXVV = 657
VFMERGEVFM = 658
VFMINVF = 659
VFMINVV = 660
VFMSACVF = 661
VFMSACVV = 662
VFMSUBVF = 663
VFMSUBVV = 664
VFMULVF = 665
VFMULVV = 666
VFMVFS = 667
VFMVSF = 668
VFMVVF = 669
VFNCVTFFW = 670
VFNCVTFXW = 671
VFNCVTFXUW = 672
VFNCVTRODFFW = 673
VFNCVTRTZXFW = 674
VFNCVTRTZXUFW = 675
VFNCVTXFW = 676
VFNCVTXUFW = 677
VFNCVTBF16FFW = 678
VFNMACCVF = 679
VFNMACCVV = 680
VFNMADDVF = 681
VFNMADDVV = 682
VFNMSACVF = 683
VFNMSACVV = 684
VFNMSUBVF = 685
VFNMSUBVV = 686
VFRDIVVF = 687
VFREC7V = 688
VFREDMAXVS = 689
VFREDMINVS = 690
VFREDOSUMVS = 691
VFREDSUMVS = 692
VFREDUSUMVS = 693
VFRSQRT7V = 694
VFRSUBVF = 695
VFSGNJVF = 696
VFSGNJVV = 697
VFSGNJNVF = 698
VFSGNJNVV = 699
VFSGNJXVF = 700
VFSGNJXVV = 701
VFSLIDE1DOWNVF = 702
VFSLIDE1UPVF = 703
VFSQRTV = 704
VFSUBVF = 705
VFSUBVV = 706
VFWADDVF = 707
VFWADDVV = 708
VFWADDWF = 709
VFWADDWV = 710
VFWCVTFFV = 711
VFWCVTFXV = 712
VFWCVTFXUV = 713
VFWCVTRTZXFV = 714
VFWCVTRTZXUFV = 715
VFWCVTXFV = 716
VFWCVTXUFV = 717
VFWCVTBF16FFV = 718
VFWMACCVF = 719
VFWMACCVV = 720
VFWMACCBF16VF = 721
VFWMACCBF16VV = 722
VFWMSACVF = 723
VFWMSACVV = 724
VFWMULVF = 725
VFWMULVV = 726
VFWNMACCVF = 727
VFWNMACCVV = 728
VFWNMSACVF = 729
VFWNMSACVV = 730
VFWREDOSUMVS = 731
VFWREDSUMVS = 732
VFWREDUSUMVS = 733
VFWSUBVF = 734
VFWSUBVV = 735
VFWSUBWF = 736
VFWSUBWV = 737
VGHSHVV = 738
VGMULVV = 739
VIDV = 740
VIOTAM = 741
VL1RV = 742
VL1RE16V = 743
VL1RE32V = 744
VL1RE64V = 745
VL1RE8V = 746
VL2RV = 747
VL2RE16V = 748
VL2RE32V = 749
VL2RE64V = 750
VL2RE8V = 751
VL4RV = 752
VL4RE16V = 753
VL4RE32V = 754
VL4RE64V = 755
VL4RE8V = 756
VL8RV = 757
VL8RE16V = 758
VL8RE32V = 759
VL8RE64V = 760
VL8RE8V = 761
VLE16V = 762
VLE16FFV = 763
VLE1V = 764
VLE32V = 765
VLE32FFV = 766
VLE64V = 767
VLE64FFV = 768
VLE8V = 769
VLE8FFV = 770
VLMV = 771
VLOXEI16V = 772
VLOXEI32V = 773
VLOXEI64V = 774
VLOXEI8V = 775
VLSE16V = 776
VLSE32V = 777
VLSE64V = 778
VLSE8V = 779
VLUXEI16V = 780
VLUXEI32V = 781
VLUXEI64V = 782
VLUXEI8V = 783
VMACCVV = 784
VMACCVX = 785
VMADCVI = 786
VMADCVIM = 787
VMADCVV = 788
VMADCVVM = 789
VMADCVX = 790
VMADCVXM = 791
VMADDVV = 792
VMADDVX = 793
VMANDMM = 794
VMANDNMM = 795
VMANDNOTMM = 796
VMAXVV = 797
VMAXVX = 798
VMAXUVV = 799
VMAXUVX = 800
VMERGEVIM = 801
VMERGEVVM = 802
VMERGEVXM = 803
VMFEQVF = 804
VMFEQVV = 805
VMFGEVF = 806
VMFGTVF = 807
VMFLEVF = 808
VMFLEVV = 809
VMFLTVF = 810
VMFLTVV = 811
VMFNEVF = 812
VMFNEVV = 813
VMINVV = 814
VMINVX = 815
VMINUVV = 816
VMINUVX = 817
VMNANDMM = 818
VMNORMM = 819
VMORMM = 820
VMORNMM = 821
VMORNOTMM = 822
VMSBCVV = 823
VMSBCVVM = 824
VMSBCVX = 825
VMSBCVXM = 826
VMSBFM = 827
VMSEQVI = 828
VMSEQVV = 829
VMSEQVX = 830
VMSGTVI = 831
VMSGTVX = 832
VMSGTUVI = 833
VMSGTUVX = 834
VMSIFM = 835
VMSLEVI = 836
VMSLEVV = 837
VMSLEVX = 838
VMSLEUVI = 839
VMSLEUVV = 840
VMSLEUVX = 841
VMSLTVV = 842
VMSLTVX = 843
VMSLTUVV = 844
VMSLTUVX = 845
VMSNEVI = 846
VMSNEVV = 847
VMSNEVX = 848
VMSOFM = 849
VMULVV = 850
VMULVX = 851
VMULHVV = 852
VMULHVX = 853
VMULHSUVV = 854
VMULHSUVX = 855
VMULHUVV = 856
VMULHUVX = 857
VMV1RV = 858
VMV2RV = 859
VMV4RV = 860
VMV8RV = 861
VMVSX = 862
VMVVI = 863
VMVVV = 864
VMVVX = 865
VMVXS = 866
VMXNORMM = 867
VMXORMM = 868
VNCLIPWI = 869
VNCLIPWV = 870
VNCLIPWX = 871
VNCLIPUWI = 872
VNCLIPUWV = 873
VNCLIPUWX = 874
VNMSACVV = 875
VNMSACVX = 876
VNMSUBVV = 877
VNMSUBVX = 878
VNSRAWI = 879
VNSRAWV = 880
VNSRAWX = 881
VNSRLWI = 882
VNSRLWV = 883
VNSRLWX = 884
VORVI = 885
VORVV = 886
VORVX = 887
VPOPCM = 888
VREDANDVS = 889
VREDMAXVS = 890
VREDMAXUVS = 891
VREDMINVS = 892
VREDMINUVS = 893
VREDORVS = 894
VREDSUMVS = 895
VREDXORVS = 896
VREMVV = 897
VREMVX = 898
VREMUVV = 899
VREMUVX = 900
VREV8V = 901
VRGATHERVI = 902
VRGATHERVV = 903
VRGATHERVX = 904
VRGATHEREI16VV = 905
VROLVV = 906
VROLVX = 907
VRORVI = 908
VRORVV = 909
VRORVX = 910
VRSUBVI = 911
VRSUBVX = 912
VS1RV = 913
VS2RV = 914
VS4RV = 915
VS8RV = 916
VSADDVI = 917
VSADDVV = 918
VSADDVX = 919
VSADDUVI = 920
VSADDUVV = 921
VSADDUVX = 922
VSBCVVM = 923
VSBCVXM = 924
VSE16V = 925
VSE1V = 926
VSE32V = 927
VSE64V = 928
VSE8V = 929
VSETIVLI = 930
VSETVL = 931
VSETVLI = 932
VSEXTVF2 = 933
VSEXTVF4 = 934
VSEXTVF8 = 935
VSHA2CHVV = 936
VSHA2CLVV = 937
VSHA2MSVV = 938
VSLIDE1DOWNVX = 939
VSLIDE1UPVX = 940
VSLIDEDOWNVI = 941
VSLIDEDOWNVX = 942
VSLIDEUPVI = 943
VSLIDEUPVX = 944
VSLLVI = 945
VSLLVV = 946
VSLLVX = 947
VSM3CVI = 948
VSM3MEVV = 949
VSM4KVI = 950
VSM4RVS = 951
VSM4RVV = 952
VSMV = 953
VSMULVV = 954
VSMULVX = 955
VSOXEI16V = 956
VSOXEI32V = 957
VSOXEI64V = 958
VSOXEI8V = 959
VSRAVI = 960
VSRAVV = 961
VSRAVX = 962
VSRLVI = 963
VSRLVV = 964
VSRLVX = 965
VSSE16V = 966
VSSE32V = 967
VSSE64V = 968
VSSE8V = 969
VSSRAVI = 970
VSSRAVV = 971
VSSRAVX = 972
VSSRLVI = 973
VSSRLVV = 974
VSSRLVX = 975
VSSUBVV = 976
VSSUBVX = 977
VSSUBUVV = 978
VSSUBUVX = 979
VSUBVV = 980
VSUBVX = 981
VSUXEI16V = 982
VSUXEI32V = 983
VSUXEI64V = 984
VSUXEI8V = 985
VWADDVV = 986
VWADDVX = 987
VWADDWV = 988
VWADDWX = 989
VWADDUVV = 990
VWADDUVX = 991
VWADDUWV = 992
VWADDUWX = 993
VWMACCVV = 994
VWMACCVX = 995
VWMACCSUVV = 996
VWMACCSUVX = 997
VWMACCUVV = 998
VWMACCUVX = 999
VWMACCUSVX = 1000
VWMULVV = 1001
VWMULVX = 1002
VWMULSUVV = 1003
VWMULSUVX = 1004
VWMULUVV = 1005
VWMULUVX = 1006
VWREDSUMVS = 1007
VWREDSUMUVS = 1008
VWSLLVI = 1009
VWSLLVV = 1010
VWSLLVX = 1011
VWSUBVV = 1012
VWSUBVX = 1013
VWSUBWV = 1014
VWSUBWX = 1015
VWSUBUVV = 1016
VWSUBUVX = 1017
VWSUBUWV = 1018
VWSUBUWX = 1019
VXORVI = 1020
VXORVV = 1021
VXORVX = 1022
VZEXTVF2 = 1023
VZEXTVF4 = 1024
VZEXTVF8 = 1025
WFI = 1026
Wait for interrupt
Can causes the processor to enter a low-power state until the next interrupt occurs.
<%- if ext?(:H) -%>
The behavior of wfi is affected by the mstatus.TW
and hstatus.VTW bits, as summarized below.
[%autowidth,%footer]
|===
.2+| [.rotate]#mstatus.TW# .2+| [.rotate]#hstatus.VTW# 4+^.>| wfi behavior
h| HS-mode h| U-mode h| VS-mode h| in VU-mode
| 0 | 0 | Wait | Trap (I) | Wait | Trap (V) | 0 | 1 | Wait | Trap (I) | Trap (V) | Trap (V) | 1 | - | Trap (I) | Trap (I) | Trap (I) | Trap (I)
6+| Trap (I) - Trap with Illegal Instruction code +
Trap (V) - Trap with Virtual Instruction code
|===
<%- else -%>
The wfi instruction is also affected by mstatus.TW, as shown below:
[%autowidth,%footer]
|===
.2+| [.rotate]#mstatus.TW# 2+^.>| wfi behavior
h| S-mode h| U-mode
| 0 | Wait | Trap (I) | 1 | Trap (I) | Trap (I)
3+| Trap (I) - Trap with Illegal Instruction code
|===
<%- end -%>
When wfi is marked as causing a trap above, the implementation is allowed to wait
for an unspecified period of time to see if an interrupt occurs before raising the trap.
That period of time can be zero (i.e., wfi always causes a trap in the cases identified
above).
§Forms
Assembly: wfi ""
WRSNTO = 1027
WRSSTO = 1028
XNOR = 1029
Exclusive NOR
This instruction performs the bit-wise exclusive-NOR operation on rs1 and rs2.
§Forms
Assembly: xnor xd, xs1, xs2
XOR = 1030
Exclusive Or
Exclusive or rs1 with rs2, and store the result in rd
§Forms
Assembly: xor xd, xs1, xs2
XORI = 1031
Exclusive Or immediate
Exclusive or an immediate to the value in rs1, and store the result in rd
§Forms
Assembly: xori xd, xs1, imm
XPERM4 = 1032
Crossbar permutation (nibbles)
The xperm4 instruction operates on nibbles. The rs1 register contains a vector of XLEN/4 4-bit elements. The rs2 register contains a vector of XLEN/4 4-bit indexes. The result is each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 is out of bounds.
§Forms
Assembly: xperm4 xd, xs1, xs2
XPERM8 = 1033
Crossbar permutation (bytes)
The xperm8 instruction operates on bytes. The rs1 register contains a vector of XLEN/8 8-bit elements. The rs2 register contains a vector of XLEN/8 8-bit indexes. The result is each element in rs2 replaced by the indexed element in rs1, or zero if the index into rs2 is out of bounds.
§Forms
Assembly: xperm8 xd, xs1, xs2
ZEXTB = 1034
ZEXTH = 1035
Zero-extend halfword
This instruction zero-extends the least-significant halfword of the source to XLEN by inserting 0’s into all of the bits more significant than 15.
[NOTE]
The zext.h instruction is a pseudo-op for pack when Zbkb is implemented and XLEN == 32.
[NOTE]
The zext.h instruction is a pseudo-op for packw when Zbkb is implemented and XLEN == 64.
§Forms
Assembly: zext.h xd, xs1
ZEXTHRV32 = 1036
Zero-extend halfword
This instruction zero-extends the least-significant halfword of the source to XLEN by inserting 0’s into all of the bits more significant than 15.
[NOTE]
The zext.h instruction is a pseudo-op for pack when Zbkb is implemented and XLEN == 32.
[NOTE]
The zext.h instruction is a pseudo-op for packw when Zbkb is implemented and XLEN == 64.
§Forms
Assembly: zext.h.rv32 xd, xs1
ZEXTW = 1037
ZIP = 1038
Bit interleave
This instruction scatters all of the odd and even bits of a source word into the high and low halves of a destination word. It is the inverse of the unzip instruction. This instruction is available only on RV32.
§Forms
Assembly: zip xd, xs1