Skip to content

Commit 5379b6d

Browse files
committed
[𝘀𝗽𝗿] initial version
Created using spr 1.3.5-bogner
2 parents 009971a + 0ef44d5 commit 5379b6d

File tree

12 files changed

+22
-61
lines changed

12 files changed

+22
-61
lines changed

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

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -591,16 +591,7 @@ struct RISCVOperand final : public MCParsedAsmOperand {
591591
(VK == RISCVMCExpr::VK_CALL || VK == RISCVMCExpr::VK_CALL_PLT);
592592
}
593593

594-
bool isPseudoQCJumpSymbol() const {
595-
int64_t Imm;
596-
// Must be of 'immediate' type but not a constant.
597-
if (!isImm() || evaluateConstantImm(getImm(), Imm))
598-
return false;
599-
600-
RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None;
601-
return RISCVAsmParser::classifySymbolRef(getImm(), VK) &&
602-
VK == RISCVMCExpr::VK_QC_E_JUMP_PLT;
603-
}
594+
bool isPseudoQCJumpSymbol() const { return isBareSymbol(); }
604595

605596
bool isPseudoJumpSymbol() const {
606597
int64_t Imm;
@@ -2079,9 +2070,6 @@ ParseStatus RISCVAsmParser::parseBareSymbol(OperandVector &Operands) {
20792070

20802071
SMLoc E = SMLoc::getFromPointer(S.getPointer() + Identifier.size());
20812072

2082-
if (Identifier.consume_back("@plt"))
2083-
return Error(getLoc(), "'@plt' operand not valid for instruction");
2084-
20852073
MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
20862074

20872075
if (Sym->isVariable()) {
@@ -2129,8 +2117,9 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) {
21292117
Lex();
21302118
Lex();
21312119
StringRef PLT;
2120+
SMLoc Loc = getLoc();
21322121
if (getParser().parseIdentifier(PLT) || PLT != "plt")
2133-
return ParseStatus::Failure;
2122+
return Error(Loc, "@ (except the deprecated/ignored @plt) is disallowed");
21342123
} else if (!getLexer().peekTok().is(AsmToken::EndOfStatement)) {
21352124
// Avoid parsing the register in `call rd, foo` as a call symbol.
21362125
return ParseStatus::NoMatch;
@@ -2157,25 +2146,10 @@ ParseStatus RISCVAsmParser::parsePseudoQCJumpSymbol(OperandVector &Operands) {
21572146

21582147
std::string Identifier(getTok().getIdentifier());
21592148
SMLoc E = getTok().getEndLoc();
2160-
2161-
if (getLexer().peekTok().is(AsmToken::At)) {
2162-
Lex();
2163-
Lex();
2164-
SMLoc PLTLoc = getLoc();
2165-
StringRef PLT;
2166-
E = getTok().getEndLoc();
2167-
if (getParser().parseIdentifier(PLT) || PLT != "plt")
2168-
return Error(PLTLoc,
2169-
"'@plt' is the only valid operand for this instruction");
2170-
} else {
2171-
Lex();
2172-
}
2173-
2174-
RISCVMCExpr::Specifier Kind = RISCVMCExpr::VK_QC_E_JUMP_PLT;
2149+
Lex();
21752150

21762151
MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier);
21772152
Res = MCSymbolRefExpr::create(Sym, getContext());
2178-
Res = RISCVMCExpr::create(Res, Kind, getContext());
21792153
Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64()));
21802154
return ParseStatus::Success;
21812155
}

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ RISCVAsmBackend::getFixupKindInfo(MCFixupKind Kind) const {
9595
{"fixup_riscv_qc_e_branch", 0, 48, MCFixupKindInfo::FKF_IsPCRel},
9696
{"fixup_riscv_qc_e_32", 16, 32, 0},
9797
{"fixup_riscv_qc_abs20_u", 12, 20, 0},
98-
{"fixup_riscv_qc_e_jump_plt", 0, 48, MCFixupKindInfo::FKF_IsPCRel},
98+
{"fixup_riscv_qc_e_jump", 0, 48, MCFixupKindInfo::FKF_IsPCRel},
9999
};
100100
static_assert((std::size(Infos)) == RISCV::NumTargetFixupKinds,
101101
"Not all fixup kinds added to Infos array");
@@ -576,7 +576,7 @@ static uint64_t adjustFixupValue(const MCFixup &Fixup, uint64_t Value,
576576
Value = (Bit19 << 31) | (Bit14_0 << 16) | (Bit18_15 << 12);
577577
return Value;
578578
}
579-
case RISCV::fixup_riscv_qc_e_jump_plt: {
579+
case RISCV::fixup_riscv_qc_e_jump: {
580580
if (!isInt<32>(Value))
581581
Ctx.reportError(Fixup.getLoc(), "fixup value out of range");
582582
if (Value & 0x1)

llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ unsigned RISCVELFObjectWriter::getRelocType(MCContext &Ctx,
119119
return ELF::R_RISCV_CALL_PLT;
120120
case RISCV::fixup_riscv_qc_e_branch:
121121
return ELF::R_RISCV_QC_E_BRANCH;
122-
case RISCV::fixup_riscv_qc_e_jump_plt:
122+
case RISCV::fixup_riscv_qc_e_jump:
123123
return ELF::R_RISCV_QC_E_JUMP_PLT;
124124
}
125125
}

llvm/lib/Target/RISCV/MCTargetDesc/RISCVFixupKinds.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ enum Fixups {
8585
// 20-bit fixup for symbol references in the 32-bit qc.li instruction
8686
fixup_riscv_qc_abs20_u,
8787
// 32-bit fixup for symbol references in the 48-bit qc.j/qc.jal instructions
88-
fixup_riscv_qc_e_jump_plt,
88+
fixup_riscv_qc_e_jump,
8989

9090
// Used as a sentinel, must be the last
9191
fixup_riscv_invalid,

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -685,9 +685,6 @@ uint64_t RISCVMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNo,
685685
case RISCVMCExpr::VK_QC_ABS20:
686686
FixupKind = RISCV::fixup_riscv_qc_abs20_u;
687687
break;
688-
case RISCVMCExpr::VK_QC_E_JUMP_PLT:
689-
FixupKind = RISCV::fixup_riscv_qc_e_jump_plt;
690-
break;
691688
}
692689
} else if (Kind == MCExpr::SymbolRef || Kind == MCExpr::Binary) {
693690
// FIXME: Sub kind binary exprs have chance of underflow.
@@ -705,6 +702,8 @@ uint64_t RISCVMCCodeEmitter::getImmOpValue(const MCInst &MI, unsigned OpNo,
705702
FixupKind = RISCV::fixup_riscv_qc_e_branch;
706703
} else if (MIFrm == RISCVII::InstFormatQC_EAI) {
707704
FixupKind = RISCV::fixup_riscv_qc_e_32;
705+
} else if (MIFrm == RISCVII::InstFormatQC_EJ) {
706+
FixupKind = RISCV::fixup_riscv_qc_e_jump;
708707
}
709708
}
710709

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ const RISCVMCExpr *RISCVMCExpr::create(const MCExpr *Expr, Specifier S,
3434

3535
void RISCVMCExpr::printImpl(raw_ostream &OS, const MCAsmInfo *MAI) const {
3636
Specifier S = getSpecifier();
37-
bool HasVariant = ((S != VK_None) && (S != VK_CALL) && (S != VK_CALL_PLT) &&
38-
(S != VK_QC_E_JUMP_PLT));
37+
bool HasVariant = ((S != VK_None) && (S != VK_CALL) && (S != VK_CALL_PLT));
3938

4039
if (HasVariant)
4140
OS << '%' << getSpecifierName(S) << '(';
@@ -168,8 +167,6 @@ StringRef RISCVMCExpr::getSpecifierName(Specifier S) {
168167
return "pltpcrel";
169168
case VK_QC_ABS20:
170169
return "qc.abs20";
171-
case VK_QC_E_JUMP_PLT:
172-
return "qc_e_jump_plt";
173170
}
174171
llvm_unreachable("Invalid ELF symbol kind");
175172
}

llvm/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ class RISCVMCExpr : public MCTargetExpr {
4444
VK_TLSDESC_ADD_LO,
4545
VK_TLSDESC_CALL,
4646
VK_QC_ABS20,
47-
VK_QC_E_JUMP_PLT
4847
};
4948

5049
private:

llvm/lib/Target/RISCV/RISCVInstrInfoXqci.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ def PseudoQCJumpSymbol : AsmOperandClass {
158158
let RenderMethod = "addImmOperands";
159159
let DiagnosticType = "InvalidPseudoQCJumpSymbol";
160160
let DiagnosticString = "operand must be a valid jump target";
161-
let ParserMethod = "parsePseudoQCJumpSymbol";
161+
let ParserMethod = "parseBareSymbol";
162162
}
163163

164164
def pseudo_qc_jump_symbol : Operand<XLenVT> {

llvm/test/MC/RISCV/function-call-invalid.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ call %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1010
call %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1111
call %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1212
call foo, bar # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
13+
call foo@pls # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed

llvm/test/MC/RISCV/tail-call-invalid.s

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ tail %hi(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1010
tail %lo(1234) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1111
tail %hi(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
1212
tail %lo(foo) # CHECK: :[[@LINE]]:6: error: operand must be a bare symbol name
13+
tail foo@pls # CHECK: :[[@LINE]]:10: error: @ (except the deprecated/ignored @plt) is disallowed

0 commit comments

Comments
 (0)