Skip to content

Commit 49ce038

Browse files
authored
RISCVAsmParser: Replace "modifier" with "specifier" in diagnostics
Use the preferred "specifier" term for relocation specifier. "Relocation modifier" suggests adjustments happen during the linker's relocation step rather than the assembler's expression evaluation. The term "relocation specifier" is preferred by Arm for :lower16: and IBM AIX, and I am trying to standardize in MC. Pull Request: #132565
1 parent 06fd10f commit 49ce038

18 files changed

+85
-85
lines changed

llvm/lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ class RISCVAsmParser : public MCTargetAsmParser {
199199
ParseStatus parseRegister(OperandVector &Operands, bool AllowParens = false);
200200
ParseStatus parseMemOpBaseReg(OperandVector &Operands);
201201
ParseStatus parseZeroOffsetMemOp(OperandVector &Operands);
202-
ParseStatus parseOperandWithModifier(OperandVector &Operands);
202+
ParseStatus parseOperandWithSpecifier(OperandVector &Operands);
203203
ParseStatus parseBareSymbol(OperandVector &Operands);
204204
ParseStatus parseCallSymbol(OperandVector &Operands);
205205
ParseStatus parsePseudoJumpSymbol(OperandVector &Operands);
@@ -1746,7 +1746,7 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
17461746
case Match_InvalidSImm12:
17471747
return generateImmOutOfRangeError(
17481748
Operands, ErrorInfo, -(1 << 11), (1 << 11) - 1,
1749-
"operand must be a symbol with %lo/%pcrel_lo/%tprel_lo modifier or an "
1749+
"operand must be a symbol with %lo/%pcrel_lo/%tprel_lo specifier or an "
17501750
"integer in the range");
17511751
case Match_InvalidSImm12Lsb0:
17521752
return generateImmOutOfRangeError(
@@ -1765,17 +1765,19 @@ bool RISCVAsmParser::matchAndEmitInstruction(SMLoc IDLoc, unsigned &Opcode,
17651765
Operands, ErrorInfo, -(1 << 15), (1 << 15) - 1,
17661766
"immediate must be non-zero in the range");
17671767
case Match_InvalidUImm20LUI:
1768-
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 20) - 1,
1769-
"operand must be a symbol with "
1770-
"%hi/%tprel_hi modifier or an integer in "
1771-
"the range");
1768+
return generateImmOutOfRangeError(
1769+
Operands, ErrorInfo, 0, (1 << 20) - 1,
1770+
"operand must be a symbol with "
1771+
"%hi/%tprel_hi specifier or an integer in "
1772+
"the range");
17721773
case Match_InvalidUImm20:
17731774
return generateImmOutOfRangeError(Operands, ErrorInfo, 0, (1 << 20) - 1);
17741775
case Match_InvalidUImm20AUIPC:
17751776
return generateImmOutOfRangeError(
17761777
Operands, ErrorInfo, 0, (1 << 20) - 1,
17771778
"operand must be a symbol with a "
1778-
"%pcrel_hi/%got_pcrel_hi/%tls_ie_pcrel_hi/%tls_gd_pcrel_hi modifier or "
1779+
"%pcrel_hi/%got_pcrel_hi/%tls_ie_pcrel_hi/%tls_gd_pcrel_hi specifier "
1780+
"or "
17791781
"an integer in the range");
17801782
case Match_InvalidSImm21Lsb0JAL:
17811783
return generateImmOutOfRangeError(
@@ -2220,26 +2222,24 @@ ParseStatus RISCVAsmParser::parseImmediate(OperandVector &Operands) {
22202222
return ParseStatus::Failure;
22212223
break;
22222224
case AsmToken::Percent:
2223-
return parseOperandWithModifier(Operands);
2225+
return parseOperandWithSpecifier(Operands);
22242226
}
22252227

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

2230-
ParseStatus RISCVAsmParser::parseOperandWithModifier(OperandVector &Operands) {
2232+
ParseStatus RISCVAsmParser::parseOperandWithSpecifier(OperandVector &Operands) {
22312233
SMLoc S = getLoc();
22322234
SMLoc E;
22332235

2234-
if (parseToken(AsmToken::Percent, "expected '%' for operand modifier"))
2235-
return ParseStatus::Failure;
2236-
2237-
if (getLexer().getKind() != AsmToken::Identifier)
2238-
return Error(getLoc(), "expected valid identifier for operand modifier");
2236+
if (!parseOptionalToken(AsmToken::Percent) ||
2237+
getLexer().getKind() != AsmToken::Identifier)
2238+
return Error(getLoc(), "expected '%' relocation specifier");
22392239
StringRef Identifier = getParser().getTok().getIdentifier();
22402240
auto Spec = RISCVMCExpr::getSpecifierForName(Identifier);
22412241
if (!Spec)
2242-
return Error(getLoc(), "unrecognized operand modifier");
2242+
return Error(getLoc(), "invalid relocation specifier");
22432243

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

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

37513751
return false;

llvm/lib/Target/RISCV/RISCVInstrInfo.td

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -365,8 +365,8 @@ def TPRelAddSymbol : AsmOperandClass {
365365
let Name = "TPRelAddSymbol";
366366
let RenderMethod = "addImmOperands";
367367
let DiagnosticType = "InvalidTPRelAddSymbol";
368-
let DiagnosticString = "operand must be a symbol with %tprel_add modifier";
369-
let ParserMethod = "parseOperandWithModifier";
368+
let DiagnosticString = "operand must be a symbol with %tprel_add specifier";
369+
let ParserMethod = "parseOperandWithSpecifier";
370370
}
371371

372372
// A bare symbol with the %tprel_add variant.
@@ -1792,8 +1792,8 @@ def TLSDESCCallSymbol : AsmOperandClass {
17921792
let Name = "TLSDESCCallSymbol";
17931793
let RenderMethod = "addImmOperands";
17941794
let DiagnosticType = "InvalidTLSDESCCallSymbol";
1795-
let DiagnosticString = "operand must be a symbol with %tlsdesc_call modifier";
1796-
let ParserMethod = "parseOperandWithModifier";
1795+
let DiagnosticString = "operand must be a symbol with %tlsdesc_call specifier";
1796+
let ParserMethod = "parseOperandWithSpecifier";
17971797
}
17981798

17991799
// A bare symbol with the %tlsdesc_call variant.

llvm/test/MC/RISCV/corev/XCVelw-invalid.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ cv.elw 0, 0(x6)
88
# CHECK-ERROR: invalid operand for instruction
99

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

1313
cv.elw x12, x1(2047)
1414
# CHECK-ERROR: unexpected token

llvm/test/MC/RISCV/corev/XCVmem-invalid.s

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ cv.lb 0, (0), t2
1111
# CHECK-ERROR: :[[@LINE-1]]:7: error: invalid operand for instruction
1212

1313
cv.lb t0, (t1), -2049
14-
# 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]
14+
# 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]
1515

1616
cv.lb t0, (t1), 2048
17-
# 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]
17+
# 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]
1818

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

4343
cv.lbu t0, (t1), -2049
44-
# 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]
44+
# 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]
4545

4646
cv.lbu t0, (t1), 2048
47-
# 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]
47+
# 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]
4848

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

7373
cv.lh t0, (t1), -2049
74-
# 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]
74+
# 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]
7575

7676
cv.lh t0, (t1), 2048
77-
# 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]
77+
# 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]
7878

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

106106
cv.lhu t0, (t1), -2049
107-
# 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]
107+
# 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]
108108

109109
cv.lhu t0, (t1), 2048
110-
# 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]
110+
# 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]
111111

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

139139
cv.lw t0, (t1), -2049
140-
# 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]
140+
# 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]
141141

142142
cv.lw t0, (t1), 2048
143-
# 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]
143+
# 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]
144144

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

172172
cv.sb t0, (t1), 2048
173-
# 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]
173+
# 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]
174174

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

193193
cv.sh t0, (t1), 2048
194-
# 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]
194+
# 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]
195195

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

214214
cv.sw t0, (t1), 2048
215-
# 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]
215+
# 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]
216216

217217
cv.sw t0, (0), t1
218218
# CHECK-ERROR: :[[@LINE-1]]:11: error: operands must be register and register

llvm/test/MC/RISCV/insn-invalid.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
.insn i 0x13, 0, a0, a1 # CHECK: :[[@LINE]]:1: error: too few operands for instruction
1010

1111
.insn r 0x33, 0, 0, a0, 13 # CHECK: :[[@LINE]]:28: error: invalid operand for instruction
12-
.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]
12+
.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]
1313

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

llvm/test/MC/RISCV/rv32d-invalid.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Out of range immediates
44
## simm12
5-
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]
6-
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]
5+
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]
6+
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]
77

88
# Memory operand not formatted correctly
99
fld ft1, a0, -200 # CHECK: :[[@LINE]]:14: error: invalid operand for instruction

llvm/test/MC/RISCV/rv32f-invalid.s

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22

33
# Out of range immediates
44
## simm12
5-
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]
6-
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]
5+
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]
6+
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]
77

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

0 commit comments

Comments
 (0)