Changeset View
Changeset View
Standalone View
Standalone View
llvm/lib/Target/LoongArch/LoongArchFloat64InstrInfo.td
Show First 20 Lines • Show All 125 Lines • ▼ Show 20 Lines | |||||
} // Predicates = [HasBasicD] | } // Predicates = [HasBasicD] | ||||
// Instructions only available on LA64 | // Instructions only available on LA64 | ||||
let Predicates = [HasBasicD, IsLA64] in { | let Predicates = [HasBasicD, IsLA64] in { | ||||
def MOVGR2FR_D : FP_MOV<0b0000000100010100101010, "movgr2fr.d", FPR64, GPR>; | def MOVGR2FR_D : FP_MOV<0b0000000100010100101010, "movgr2fr.d", FPR64, GPR>; | ||||
def MOVFR2GR_D : FP_MOV<0b0000000100010100101110, "movfr2gr.d", GPR, FPR64>; | def MOVFR2GR_D : FP_MOV<0b0000000100010100101110, "movfr2gr.d", GPR, FPR64>; | ||||
} // Predicates = [HasBasicD, IsLA64] | } // Predicates = [HasBasicD, IsLA64] | ||||
// Instructions only available on LA32 | |||||
let Predicates = [HasBasicD, IsLA32], isCodeGenOnly = 1 in { | |||||
def MOVGR2FR_W_64 : FP_MOV<0b0000000100010100101001, "movgr2fr.w", FPR64, GPR>; | |||||
} // Predicates = [HasBasicD, IsLA32], isCodeGenOnly = 1 | |||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
// Pseudo-instructions and codegen patterns | // Pseudo-instructions and codegen patterns | ||||
//===----------------------------------------------------------------------===// | //===----------------------------------------------------------------------===// | ||||
let Predicates = [HasBasicD] in { | let Predicates = [HasBasicD] in { | ||||
/// Float arithmetic operations | /// Float arithmetic operations | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | |||||
/// Loads | /// Loads | ||||
defm : LdPat<load, FLD_D, f64>; | defm : LdPat<load, FLD_D, f64>; | ||||
/// Stores | /// Stores | ||||
defm : StPat<store, FST_D, FPR64, f64>; | defm : StPat<store, FST_D, FPR64, f64>; | ||||
} // Predicates = [HasBasicD] | } // Predicates = [HasBasicD] | ||||
/// Floating point constants | |||||
let Predicates = [HasBasicD, IsLA64] in { | |||||
def : Pat<(f64 fpimm0), (MOVGR2FR_D R0)>; | |||||
def : Pat<(f64 fpimm0neg), (FNEG_D (MOVGR2FR_D R0))>; | |||||
def : Pat<(f64 fpimm1), (FFINT_D_L (MOVGR2FR_D (ADDI_D R0, 1)))>; | |||||
} // Predicates = [HasBasicD, IsLA64] | |||||
let Predicates = [HasBasicD, IsLA32] in { | |||||
def : Pat<(f64 fpimm0), (MOVGR2FRH_W (MOVGR2FR_W_64 R0), R0)>; | |||||
def : Pat<(f64 fpimm0neg), (FNEG_D (MOVGR2FRH_W (MOVGR2FR_W_64 R0), R0))>; | |||||
xen0n: Are we better off handling this by just hard-coding the bit patterns then `movgr2fr.w` and… | |||||
Thanks for the suggestion, I will change that. gonglingqin: Thanks for the suggestion, I will change that. | |||||
def : Pat<(f64 fpimm1), (FCVT_D_S (FFINT_S_W (MOVGR2FR_W (ADDI_W R0, 1))))>; | |||||
} // Predicates = [HasBasicD, IsLA32] |
Are we better off handling this by just hard-coding the bit patterns then movgr2fr.w and movgr2frh.w? I don't know the exact latencies for fcvt.d.s but plain moves should be a bit faster.