[PATCH] D55335: [RISCV, WIP] Support assembling @plt symbol operands

Roger Ferrer Ibanez via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 5 12:24:16 PST 2018


rogfer01 added a comment.

Would it make sense to add an operand that allows a bare symbol or bare symbol + `@plt` and use it only in `CALL` and `TAIL` instead of allowing `identifier at plt` everywhere?

Perhaps that'd be too restrictive and prevent legitimate references to `@plt` references in other instructions?

I did something like this in my downstream in `RISCVInstrInfo.td`

  def BareSymbolOrPlt : AsmOperandClass {
    let Name = "BareSymbolOrPlt";
    let RenderMethod = "addImmOperands";
    let DiagnosticType = "InvalidBareSymbolOrPlt";
    let ParserMethod = "parseBareSymbolOrPlt";
  }
  
  // A bare symbol optionally decorated with @plt.
  def bare_symbol_or_plt : Operand<XLenVT> {
    let ParserMatchClass = BareSymbolOrPlt;
    let MCOperandPredicate = [{
       return MCOp.isBareSymbolRef();
    }];
  }

This will require new functions in `RISCVAsmParser.cpp` and additional diagnostic handling but nothing too onerous.

And then in `CALL` (similarly thing for `TAIL`) in `RISCVInstrInfo.td`

  let isCall = 1, Defs = [X1], isCodeGenOnly = 0, Size = 8 in
  def PseudoCALL : Pseudo<(outs), (ins bare_symbol_or_plt:$func),
                          [(Call tglobaladdr:$func)]> {
    let AsmString = "call\t$func";
  }

If this is feasible, a nice feature is that we can give a slightly better diagnostic.

Thoughts?


Repository:
  rL LLVM

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D55335/new/

https://reviews.llvm.org/D55335





More information about the llvm-commits mailing list