Index: lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp =================================================================== --- lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp +++ lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp @@ -966,6 +966,7 @@ case AsmToken::LParen: case AsmToken::Minus: case AsmToken::Plus: + case AsmToken::Tilde: case AsmToken::Integer: case AsmToken::String: { if (getParser().parseExpression(Res)) @@ -1032,6 +1033,7 @@ case AsmToken::LParen: case AsmToken::Minus: case AsmToken::Plus: + case AsmToken::Tilde: case AsmToken::Integer: case AsmToken::String: case AsmToken::Identifier: Index: test/MC/RISCV/rv32i-valid.s =================================================================== --- test/MC/RISCV/rv32i-valid.s +++ test/MC/RISCV/rv32i-valid.s @@ -90,6 +90,9 @@ jalr a0, a1, -2048 # CHECK-ASM-AND-OBJ: jalr a0, a1, -2048 # CHECK-ASM: encoding: [0x67,0x85,0x05,0x80] +jalr a0, a1, ~2047 +# CHECK-ASM-AND-OBJ: jalr a0, a1, -2048 +# CHECK-ASM: encoding: [0x67,0x85,0x05,0x80] jalr a0, a1, %lo(2048) # CHECK-ASM-AND-OBJ: jalr t2, t1, 2047 # CHECK-ASM: encoding: [0xe7,0x03,0xf3,0x7f] @@ -137,6 +140,9 @@ lh t1, -2048(zero) # CHECK-ASM-AND-OBJ: lh t1, -2048(zero) # CHECK-ASM: encoding: [0x03,0x13,0x00,0x80] +lh t1, ~2047(zero) +# CHECK-ASM-AND-OBJ: lh t1, -2048(zero) +# CHECK-ASM: encoding: [0x03,0x13,0x00,0x80] lh t1, %lo(2048)(zero) # CHECK-ASM-AND-OBJ: lh sp, 2047(a0) # CHECK-ASM: encoding: [0x03,0x11,0xf5,0x7f] @@ -166,6 +172,9 @@ sh t3, -2048(t5) # CHECK-ASM-AND-OBJ: sh t3, -2048(t5) # CHECK-ASM: encoding: [0x23,0x10,0xcf,0x81] +sh t3, ~2047(t5) +# CHECK-ASM-AND-OBJ: sh t3, -2048(t5) +# CHECK-ASM: encoding: [0x23,0x10,0xcf,0x81] sh t3, %lo(2048)(t5) # CHECK-ASM-AND-OBJ: sw ra, 999(zero) # CHECK-ASM: encoding: [0xa3,0x23,0x10,0x3e] @@ -199,6 +208,9 @@ ori a0, a1, -2048 # CHECK-ASM-AND-OBJ: ori a0, a1, -2048 # CHECK-ASM: encoding: [0x13,0xe5,0x05,0x80] +ori a0, a1, ~2047 +# CHECK-ASM-AND-OBJ: ori a0, a1, -2048 +# CHECK-ASM: encoding: [0x13,0xe5,0x05,0x80] ori a0, a1, %lo(2048) # CHECK-ASM-AND-OBJ: andi ra, sp, 2047 # CHECK-ASM: encoding: [0x93,0x70,0xf1,0x7f]