Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RISCVAsmParser: Replace "modifier" with "specifier" in diagnostics #132565

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 17 additions & 17 deletions llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
ParseStatus parseRegister(OperandVector &Operands, bool AllowParens = false);
ParseStatus parseMemOpBaseReg(OperandVector &Operands);
ParseStatus parseZeroOffsetMemOp(OperandVector &Operands);
ParseStatus parseOperandWithModifier(OperandVector &Operands);
ParseStatus parseOperandWithSpecifier(OperandVector &Operands);
ParseStatus parseBareSymbol(OperandVector &Operands);
ParseStatus parseCallSymbol(OperandVector &Operands);
ParseStatus parsePseudoJumpSymbol(OperandVector &Operands);
Expand Down Expand Up @@ -1746,7 +1746,7 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
case Match_InvalidSImm12:
return generateImmOutOfRangeError(
Operands, ErrorInfo, -(1 << 11), (1 << 11) - 1,
"operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an "
"operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an "
"integer in the range");
case Match_InvalidSImm12Lsb0:
return generateImmOutOfRangeError(
Expand All @@ -1765,17 +1765,19 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
Operands, ErrorInfo, -(1 << 15), (1 << 15) - 1,
"immediate must be non-zero in the range");
case Match_InvalidUImm20LUI:
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 20) - 1,
"operand must be a symbol with "
"%hi/%tprel_hi modifier or an integer in "
"the range");
return generateImmOutOfRangeError(
Operands, ErrorInfo, 0, (1 << 20) - 1,
"operand must be a symbol with "
"%hi/%tprel_hi specifier or an integer in "
"the range");
case Match_InvalidUImm20:
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 20) - 1);
case Match_InvalidUImm20AUIPC:
return generateImmOutOfRangeError(
Operands, ErrorInfo, 0, (1 << 20) - 1,
"operand must be a symbol with a "
"%pcrel_hi/%got_pcrel_hi/%tls_ie_pcrel_hi/%tls_gd_pcrel_hi modifier or "
"%pcrel_hi/%got_pcrel_hi/%tls_ie_pcrel_hi/%tls_gd_pcrel_hi specifier "
"or "
"an integer in the range");
case Match_InvalidSImm21Lsb0JAL:
return generateImmOutOfRangeError(
Expand Down Expand Up @@ -2220,26 +2222,24 @@ ParseStatus RISCVAsmParser::parseImmediate(OperandVector &Operands) {
return ParseStatus::Failure;
break;
case AsmToken::Percent:
return parseOperandWithModifier(Operands);
return parseOperandWithSpecifier(Operands);
}

Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64()));
return ParseStatus::Success;
}

ParseStatus RISCVAsmParser::parseOperandWithModifier(OperandVector &Operands) {
ParseStatus RISCVAsmParser::parseOperandWithSpecifier(OperandVector &Operands) {
SMLoc S = getLoc();
SMLoc E;

if (parseToken(AsmToken::Percent, "expected '%' for operand modifier"))
return ParseStatus::Failure;

if (getLexer().getKind() != AsmToken::Identifier)
return Error(getLoc(), "expected valid identifier for operand modifier");
if (!parseOptionalToken(AsmToken::Percent) ||
getLexer().getKind() != AsmToken::Identifier)
return Error(getLoc(), "expected '%' relocation specifier");
StringRef Identifier = getParser().getTok().getIdentifier();
auto Spec = RISCVMCExpr::getSpecifierForName(Identifier);
if (!Spec)
return Error(getLoc(), "unrecognized operand modifier");
return Error(getLoc(), "invalid relocation specifier");

getParser().Lex(); // Eat the identifier
if (parseToken(AsmToken::LParen, "expected '('"))
Expand Down Expand Up @@ -3732,7 +3732,7 @@ bool RISCVAsmParser::checkPseudoAddTPRel(MCInst &Inst,
if (Inst.getOperand(2).getReg() != RISCV::X4) {
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[3]).getStartLoc();
return Error(ErrorLoc, "the second input operand must be tp/x4 when using "
"%tprel_add modifier");
"%tprel_add specifier");
}

return false;
Expand All @@ -3745,7 +3745,7 @@ bool RISCVAsmParser::checkPseudoTLSDESCCall(MCInst &Inst,
if (Inst.getOperand(0).getReg() != RISCV::X5) {
SMLoc ErrorLoc = ((RISCVOperand &)*Operands[3]).getStartLoc();
return Error(ErrorLoc, "the output operand must be t0/x5 when using "
"%tlsdesc_call modifier");
"%tlsdesc_call specifier");
}

return false;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/RISCV/RISCVInstrInfo.td
Original file line number Diff line number Diff line change
Expand Up @@ -365,8 +365,8 @@ def TPRelAddSymbol : AsmOperandClass {
let Name = "TPRelAddSymbol";
let RenderMethod = "addImmOperands";
let DiagnosticType = "InvalidTPRelAddSymbol";
let DiagnosticString = "operand must be a symbol with %tprel_add modifier";
let ParserMethod = "parseOperandWithModifier";
let DiagnosticString = "operand must be a symbol with %tprel_add specifier";
let ParserMethod = "parseOperandWithSpecifier";
}

// A bare symbol with the %tprel_add variant.
Expand Down Expand Up @@ -1792,8 +1792,8 @@ def TLSDESCCallSymbol : AsmOperandClass {
let Name = "TLSDESCCallSymbol";
let RenderMethod = "addImmOperands";
let DiagnosticType = "InvalidTLSDESCCallSymbol";
let DiagnosticString = "operand must be a symbol with %tlsdesc_call modifier";
let ParserMethod = "parseOperandWithModifier";
let DiagnosticString = "operand must be a symbol with %tlsdesc_call specifier";
let ParserMethod = "parseOperandWithSpecifier";
}

// A bare symbol with the %tlsdesc_call variant.
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/RISCV/corev/XCVelw-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ cv.elw 0, 0(x6)
# CHECK-ERROR: invalid operand for instruction

cv.elw x12, 2048(x6)
# CHECK-ERROR: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.elw x12, x1(2047)
# CHECK-ERROR: unexpected token
Expand Down
26 changes: 13 additions & 13 deletions llvm/test/MC/RISCV/corev/XCVmem-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ cv.lb 0, (0), t2
# CHECK-ERROR: :[[@LINE-1]]:7: error: invalid operand for instruction

cv.lb t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lb t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lb t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register
Expand All @@ -41,10 +41,10 @@ cv.lbu 0, (0), t0
# CHECK-ERROR: :[[@LINE-1]]:8: error: invalid operand for instruction

cv.lbu t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lbu t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lbu t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:12: error: operands must be register and register
Expand All @@ -71,10 +71,10 @@ cv.lh 0, (0), t2
# CHECK-ERROR: :[[@LINE-1]]:7: error: invalid operand for instruction

cv.lh t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lh t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lh t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register
Expand Down Expand Up @@ -104,10 +104,10 @@ cv.lhu 0, 0(t1)
# CHECK-ERROR: :[[@LINE-1]]:8: error: invalid operand for instruction

cv.lhu t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lhu t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:18: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lhu t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:12: error: operands must be register and register
Expand Down Expand Up @@ -137,10 +137,10 @@ cv.lw 0, (0), t2
# CHECK-ERROR: :[[@LINE-1]]:7: error: invalid operand for instruction

cv.lw t0, (t1), -2049
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lw t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.lw t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register
Expand Down Expand Up @@ -170,7 +170,7 @@ cv.sb t0, 0(t1)
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register

cv.sb t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.sb t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register
Expand All @@ -191,7 +191,7 @@ cv.sh t0, 0(t1)
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register

cv.sh t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.sh t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register
Expand All @@ -212,7 +212,7 @@ cv.sw t0, 0(t1)
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register

cv.sw t0, (t1), 2048
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
# CHECK-ERROR: :[[@LINE-1]]:17: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

cv.sw t0, (0), t1
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/MC/RISCV/insn-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
.insn i 0x13, 0, a0, a1 # CHECK: :[[@LINE]]:1: error: too few operands for instruction

.insn r 0x33, 0, 0, a0, 13 # CHECK: :[[@LINE]]:28: error: invalid operand for instruction
.insn i 0x13, 0, a0, a1, a2 # CHECK: :[[@LINE]]:28: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
.insn i 0x13, 0, a0, a1, a2 # CHECK: :[[@LINE]]:28: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

.insn q 0x13, 0, a0, a1, 13, 14 # CHECK: :[[@LINE]]:7: error: invalid instruction format

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/RISCV/rv32d-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Out of range immediates
## simm12
fld ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
fsd ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
fld ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
fsd ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

# Memory operand not formatted correctly
fld ft1, a0, -200 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/MC/RISCV/rv32f-invalid.s
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

# Out of range immediates
## simm12
flw ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
fsw ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an integer in the range [-2048, 2047]
flw ft1, -2049(a0) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]
fsw ft2, 2048(a1) # CHECK: :[[@LINE]]:10: error: operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an integer in the range [-2048, 2047]

# Memory operand not formatted correctly
flw ft1, a0, -200 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction
Expand Down
Loading