diff options
| author | Alex Bradbury <asb@lowrisc.org> | 2018-10-25 12:45:20 +0000 | 
|---|---|---|
| committer | Alex Bradbury <asb@lowrisc.org> | 2018-10-25 12:45:20 +0000 | 
| commit | 74d4931da2fc5446d37c0335ca4349d10dbc62c7 (patch) | |
| tree | df88611120cecb6ce36eddcee0daa2fa630855b5 /llvm/lib/Target | |
| parent | 0573b8d8b689c9ac89a4f83d029cff36307fe7f3 (diff) | |
| download | bcm5719-llvm-74d4931da2fc5446d37c0335ca4349d10dbc62c7.tar.gz bcm5719-llvm-74d4931da2fc5446d37c0335ca4349d10dbc62c7.zip | |
[RISCV] Use PatFrags for variable shift patterns
This follows SystemZ and I think is cleaner vs the multiclass.
llvm-svn: 345262
Diffstat (limited to 'llvm/lib/Target')
| -rw-r--r-- | llvm/lib/Target/RISCV/RISCVInstrInfo.td | 19 | 
1 files changed, 9 insertions, 10 deletions
| diff --git a/llvm/lib/Target/RISCV/RISCVInstrInfo.td b/llvm/lib/Target/RISCV/RISCVInstrInfo.td index 50012569a74..631a1f7deca 100644 --- a/llvm/lib/Target/RISCV/RISCVInstrInfo.td +++ b/llvm/lib/Target/RISCV/RISCVInstrInfo.td @@ -206,7 +206,7 @@ def ixlenimm : Operand<XLenVT> {  def simm32     : ImmLeaf<XLenVT, [{return isInt<32>(Imm);}]>;  def simm32hi20 : ImmLeaf<XLenVT, [{return isShiftedInt<20, 12>(Imm);}]>;  // A mask value that won't affect significant shift bits. -def immshiftxlen : ImmLeaf<XLenVT, [{ +def immbottomxlenset : ImmLeaf<XLenVT, [{    if (Subtarget->is64Bit())      return countTrailingOnes<uint64_t>(Imm) >= 6;    return countTrailingOnes<uint64_t>(Imm) >= 5; @@ -660,15 +660,14 @@ def : PatGprUimmLog2XLen<sra, SRAI>;  // typically introduced when the legalizer promotes the shift amount and  // zero-extends it). For RISC-V, the mask is unnecessary as shifts in the base  // ISA only read the least significant 5 bits (RV32I) or 6 bits (RV64I). -multiclass VarShiftXLenPat<PatFrag ShiftOp, RVInst Inst> { -  def : Pat<(ShiftOp GPR:$rs1, GPR:$rs2), (Inst GPR:$rs1, GPR:$rs2)>; -  def : Pat<(ShiftOp GPR:$rs1, (and GPR:$rs2, immshiftxlen)), -            (Inst GPR:$rs1, GPR:$rs2)>; -} - -defm : VarShiftXLenPat<shl, SLL>; -defm : VarShiftXLenPat<srl, SRL>; -defm : VarShiftXLenPat<sra, SRA>; +class shiftop<SDPatternOperator operator> +    : PatFrags<(ops node:$val, node:$count), +               [(operator node:$val, node:$count), +                (operator node:$val, (and node:$count, immbottomxlenset))]>; + +def : PatGprGpr<shiftop<shl>, SLL>; +def : PatGprGpr<shiftop<srl>, SRL>; +def : PatGprGpr<shiftop<sra>, SRA>;  /// FrameIndex calculations | 

