-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[RISCV] Add symbol parsing support for Xqcilb long branch instructions #135044
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -202,6 +202,7 @@ class RISCVAsmParser : public MCTargetAsmParser { | |
| ParseStatus parseOperandWithSpecifier(OperandVector &Operands); | ||
| ParseStatus parseBareSymbol(OperandVector &Operands); | ||
| ParseStatus parseCallSymbol(OperandVector &Operands); | ||
| ParseStatus parsePseudoQCJumpSymbol(OperandVector &Operands); | ||
| ParseStatus parsePseudoJumpSymbol(OperandVector &Operands); | ||
| ParseStatus parseJALOffset(OperandVector &Operands); | ||
| ParseStatus parseVTypeI(OperandVector &Operands); | ||
|
|
@@ -590,6 +591,17 @@ struct RISCVOperand final : public MCParsedAsmOperand { | |
| (VK == RISCVMCExpr::VK_CALL || VK == RISCVMCExpr::VK_CALL_PLT); | ||
| } | ||
|
|
||
| bool isPseudoQCJumpSymbol() const { | ||
| int64_t Imm; | ||
| // Must be of 'immediate' type but not a constant. | ||
| if (!isImm() || evaluateConstantImm(getImm(), Imm)) | ||
| return false; | ||
|
|
||
| RISCVMCExpr::Specifier VK = RISCVMCExpr::VK_None; | ||
| return RISCVAsmParser::classifySymbolRef(getImm(), VK) && | ||
| VK == RISCVMCExpr::VK_QC_E_JUMP_PLT; | ||
| } | ||
|
|
||
| bool isPseudoJumpSymbol() const { | ||
| int64_t Imm; | ||
| // Must be of 'immediate' type but not a constant. | ||
|
|
@@ -2136,6 +2148,34 @@ ParseStatus RISCVAsmParser::parseCallSymbol(OperandVector &Operands) { | |
| return ParseStatus::Success; | ||
| } | ||
|
|
||
| ParseStatus RISCVAsmParser::parsePseudoQCJumpSymbol(OperandVector &Operands) { | ||
| SMLoc S = getLoc(); | ||
| const MCExpr *Res; | ||
|
|
||
| if (getLexer().getKind() != AsmToken::Identifier) | ||
| return ParseStatus::NoMatch; | ||
| std::string Identifier(getTok().getIdentifier()); | ||
|
|
||
| if (getLexer().peekTok().is(AsmToken::At)) { | ||
| Lex(); | ||
| Lex(); | ||
| StringRef PLT; | ||
| if (getParser().parseIdentifier(PLT) || PLT != "plt") | ||
| return ParseStatus::Failure; | ||
| } else { | ||
| Lex(); | ||
| } | ||
|
|
||
| SMLoc E = SMLoc::getFromPointer(S.getPointer() + Identifier.size()); | ||
|
||
| RISCVMCExpr::Specifier Kind = RISCVMCExpr::VK_QC_E_JUMP_PLT; | ||
|
|
||
| MCSymbol *Sym = getContext().getOrCreateSymbol(Identifier); | ||
| Res = MCSymbolRefExpr::create(Sym, getContext()); | ||
| Res = RISCVMCExpr::create(Res, Kind, getContext()); | ||
| Operands.push_back(RISCVOperand::createImm(Res, S, E, isRV64())); | ||
| return ParseStatus::Success; | ||
| } | ||
|
|
||
| ParseStatus RISCVAsmParser::parsePseudoJumpSymbol(OperandVector &Operands) { | ||
| SMLoc S = getLoc(); | ||
| SMLoc E; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,59 @@ | ||
| # RUN: llvm-mc -triple riscv32 -mattr=+experimental-xqcilb %s -show-encoding \ | ||
| # RUN: | FileCheck -check-prefix=INSTR -check-prefix=FIXUP %s | ||
| # RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+experimental-xqcilb %s -o %t.o | ||
| # RUN: llvm-readobj -r %t.o | FileCheck -check-prefix=RELOC %s | ||
|
|
||
| # Check prefixes: | ||
| # RELOC - Check the relocation in the object. | ||
| # FIXUP - Check the fixup on the instruction. | ||
| # INSTR - Check the instruction is handled properly by the ASMPrinter. | ||
|
|
||
| .text | ||
|
|
||
| qc.e.j foo | ||
| # RELOC: R_RISCV_CUSTOM195 foo 0x0 | ||
| # INSTR: qc.e.j foo | ||
| # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| qc.e.j foo@plt | ||
| # RELOC: R_RISCV_CUSTOM195 foo 0x0 | ||
| # INSTR: qc.e.j foo | ||
| # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| qc.e.jal foo@plt | ||
| # RELOC: R_RISCV_CUSTOM195 foo 0x0 | ||
| # INSTR: qc.e.jal foo | ||
| # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| qc.e.jal foo | ||
| # RELOC: R_RISCV_CUSTOM195 foo 0x0 | ||
| # INSTR: qc.e.jal foo | ||
| # FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| # Check that a label in a different section is handled similar to an undefined symbol | ||
| qc.e.j .bar | ||
| # RELOC: R_RISCV_CUSTOM195 .bar 0x0 | ||
| # INSTR: qc.e.j .bar | ||
| # FIXUP: fixup A - offset: 0, value: .bar, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| qc.e.jal .bar | ||
| # RELOC: R_RISCV_CUSTOM195 .bar 0x0 | ||
| # INSTR: qc.e.jal .bar | ||
| # FIXUP: fixup A - offset: 0, value: .bar, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| # Check that jumps to a defined symbol are handled correctly | ||
| qc.e.j .L1 | ||
| # INSTR:qc.e.j .L1 | ||
| # FIXUP: fixup A - offset: 0, value: .L1, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| qc.e.jal .L1 | ||
| # INSTR:qc.e.jal .L1 | ||
| # FIXUP: fixup A - offset: 0, value: .L1, kind: fixup_riscv_qc_e_jump_plt | ||
|
|
||
| .L1: | ||
| ret | ||
|
|
||
| .section .t2 | ||
|
|
||
| .bar: | ||
| ret |
Uh oh!
There was an error while loading. Please reload this page.