forked from OSchip/llvm-project
[RISCV] Gate float<->int and double<->int conversion patterns on IsRV32
The patterns as defined are correct only when XLen==32. This is another preparatory patch for a set of patches that flesh out RV64 codegen. llvm-svn: 343679
This commit is contained in:
parent
d464ed8c2e
commit
d934032e48
|
@ -212,13 +212,8 @@ let Predicates = [HasStdExtD] in {
|
|||
def : Pat<(fpround FPR64:$rs1), (FCVT_S_D FPR64:$rs1, 0b111)>;
|
||||
def : Pat<(fpextend FPR32:$rs1), (FCVT_D_S FPR32:$rs1)>;
|
||||
|
||||
// FP->[u]int. Round-to-zero must be used
|
||||
def : Pat<(fp_to_sint FPR64:$rs1), (FCVT_W_D FPR64:$rs1, 0b001)>;
|
||||
def : Pat<(fp_to_uint FPR64:$rs1), (FCVT_WU_D FPR64:$rs1, 0b001)>;
|
||||
|
||||
// [u]int->fp
|
||||
def : Pat<(sint_to_fp GPR:$rs1), (FCVT_D_W GPR:$rs1)>;
|
||||
def : Pat<(uint_to_fp GPR:$rs1), (FCVT_D_WU GPR:$rs1)>;
|
||||
// [u]int<->double conversion patterns must be gated on IsRV32 or IsRV64, so
|
||||
// are defined later.
|
||||
|
||||
/// Float arithmetic operations
|
||||
|
||||
|
@ -287,3 +282,13 @@ def SplitF64Pseudo
|
|||
[(set GPR:$dst1, GPR:$dst2, (RISCVSplitF64 FPR64:$src))]>;
|
||||
|
||||
} // Predicates = [HasStdExtD]
|
||||
|
||||
let Predicates = [HasStdExtD, IsRV32] in {
|
||||
// double->[u]int. Round-to-zero must be used.
|
||||
def : Pat<(fp_to_sint FPR64:$rs1), (FCVT_W_D FPR64:$rs1, 0b001)>;
|
||||
def : Pat<(fp_to_uint FPR64:$rs1), (FCVT_WU_D FPR64:$rs1, 0b001)>;
|
||||
|
||||
// [u]int->double.
|
||||
def : Pat<(sint_to_fp GPR:$rs1), (FCVT_D_W GPR:$rs1)>;
|
||||
def : Pat<(uint_to_fp GPR:$rs1), (FCVT_D_WU GPR:$rs1)>;
|
||||
} // Predicates = [HasStdExtD, IsRV32]
|
||||
|
|
|
@ -252,13 +252,8 @@ let Predicates = [HasStdExtF] in {
|
|||
def : Pat<(bitconvert GPR:$rs1), (FMV_W_X GPR:$rs1)>;
|
||||
def : Pat<(bitconvert FPR32:$rs1), (FMV_X_W FPR32:$rs1)>;
|
||||
|
||||
// FP->[u]int. Round-to-zero must be used
|
||||
def : Pat<(fp_to_sint FPR32:$rs1), (FCVT_W_S $rs1, 0b001)>;
|
||||
def : Pat<(fp_to_uint FPR32:$rs1), (FCVT_WU_S $rs1, 0b001)>;
|
||||
|
||||
// [u]int->fp. Match GCC and default to using dynamic rounding mode.
|
||||
def : Pat<(sint_to_fp GPR:$rs1), (FCVT_S_W $rs1, 0b111)>;
|
||||
def : Pat<(uint_to_fp GPR:$rs1), (FCVT_S_WU $rs1, 0b111)>;
|
||||
// [u]int32<->float conversion patterns must be gated on IsRV32 or IsRV64, so
|
||||
// are defined later.
|
||||
|
||||
/// Float arithmetic operations
|
||||
|
||||
|
@ -313,3 +308,13 @@ defm : LdPat<load, FLW>;
|
|||
defm : StPat<store, FSW, FPR32>;
|
||||
|
||||
} // Predicates = [HasStdExtF]
|
||||
|
||||
let Predicates = [HasStdExtF, IsRV32] in {
|
||||
// float->[u]int. Round-to-zero must be used.
|
||||
def : Pat<(fp_to_sint FPR32:$rs1), (FCVT_W_S $rs1, 0b001)>;
|
||||
def : Pat<(fp_to_uint FPR32:$rs1), (FCVT_WU_S $rs1, 0b001)>;
|
||||
|
||||
// [u]int->float. Match GCC and default to using dynamic rounding mode.
|
||||
def : Pat<(sint_to_fp GPR:$rs1), (FCVT_S_W $rs1, 0b111)>;
|
||||
def : Pat<(uint_to_fp GPR:$rs1), (FCVT_S_WU $rs1, 0b111)>;
|
||||
} // Predicates = [HasStdExtF, IsRV32]
|
||||
|
|
Loading…
Reference in New Issue