Skip to content

Commit

Permalink
Fixed Instruction Selection Patterns for CoreV SIMD Insert and SIMD E…
Browse files Browse the repository at this point in the history
…xtract Instructions
  • Loading branch information
adeel10x committed Nov 24, 2023
1 parent bd8f80c commit 3eb82dd
Showing 1 changed file with 19 additions and 7 deletions.
26 changes: 19 additions & 7 deletions llvm/lib/Target/RISCV/RISCVInstrInfoCOREV.td
Original file line number Diff line number Diff line change
Expand Up @@ -716,6 +716,11 @@ def trailing1sPlus1 : SDNodeXForm<imm, [{
SDLoc(N), N->getValueType(0));
}]>;

def LO6 : SDNodeXForm<imm, [{
return CurDAG->getTargetConstant(N->getZExtValue() & 0x3f,
SDLoc(N), N->getValueType(0));
}]>;

//===----------------------------------------------------------------------===//
// Patterns for MAC operations
//===----------------------------------------------------------------------===//
Expand Down Expand Up @@ -1110,13 +1115,20 @@ let Predicates = [HasExtXcvsimd, IsRV32] in {
defm SDOTUP : PatCorevTernaryUnsigned<"sdotup">;
defm SDOTUSP : PatCorevTernary<"sdotusp">;
defm SDOTSP : PatCorevTernary<"sdotsp">;

defm EXTRACT : PatCorevGprTImmHB<"extract">;
defm EXTRACTU : PatCorevGprTImmHB<"extractu">;
def : Pat<(int_riscv_cv_simd_insert_b GPR:$rd, GPR:$rs1, cv_tsimm6:$imm),
(CV_INSERT_B GPR:$rd, GPR:$rs1, cv_tsimm6:$imm)>;
def : Pat<(int_riscv_cv_simd_insert_h GPR:$rd, GPR:$rs1, cv_tsimm6:$imm),
(CV_INSERT_H GPR:$rd, GPR:$rs1, cv_tsimm6:$imm)>;

def : Pat<(int_riscv_cv_simd_insert_b GPR:$rd, GPR:$rs1, i32:$imm),
(CV_INSERT_B GPR:$rd, GPR:$rs1, (LO6 cv_uimm6:$imm))>;
def : Pat<(int_riscv_cv_simd_insert_h GPR:$rd, GPR:$rs1, i32:$imm),
(CV_INSERT_H GPR:$rd, GPR:$rs1, (LO6 cv_uimm6:$imm))>;

def : Pat<(int_riscv_cv_simd_extract_b GPR:$rs1, i32:$imm),
(CV_EXTRACT_B GPR:$rs1, (LO6 cv_uimm6:$imm))>;
def : Pat<(int_riscv_cv_simd_extract_h GPR:$rs1, i32:$imm),
(CV_EXTRACT_H GPR:$rs1, (LO6 cv_uimm6:$imm))>;
def : Pat<(int_riscv_cv_simd_extractu_b GPR:$rs1, i32:$imm),
(CV_EXTRACTU_B GPR:$rs1, (LO6 cv_uimm6:$imm))>;
def : Pat<(int_riscv_cv_simd_extractu_h GPR:$rs1, i32:$imm),
(CV_EXTRACTU_H GPR:$rs1, (LO6 cv_uimm6:$imm))>;

defm SHUFFLE : PatCorevGprGprHB<"shuffle">;
def : PatCorevGprTImm<"shuffle_sci_h", "SHUFFLE_SCI_H">;
Expand Down

0 comments on commit 3eb82dd

Please sign in to comment.