2013-05-07 00:15:19 +08:00
|
|
|
//==- SystemZInstrFP.td - Floating-point SystemZ instructions --*- tblgen-*-==//
|
|
|
|
//
|
2019-01-19 16:50:56 +08:00
|
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
2013-05-07 00:15:19 +08:00
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-12-05 19:24:39 +08:00
|
|
|
// TODO: Most floating-point instructions (except for simple moves and the
|
|
|
|
// like) can raise exceptions -- should they have hasSideEffects=1 ?
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
2013-06-27 17:27:40 +08:00
|
|
|
// Select instructions
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// C's ?: operator for floating-point operands.
|
2018-04-30 23:49:27 +08:00
|
|
|
let Predicates = [FeatureVector] in {
|
|
|
|
def SelectVR32 : SelectWrapper<f32, VR32>;
|
|
|
|
def SelectVR64 : SelectWrapper<f64, VR64>;
|
|
|
|
}
|
2017-07-18 01:44:20 +08:00
|
|
|
def SelectF32 : SelectWrapper<f32, FP32>;
|
|
|
|
def SelectF64 : SelectWrapper<f64, FP64>;
|
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in
|
|
|
|
def SelectF128 : SelectWrapper<f128, FP128>;
|
|
|
|
let Predicates = [FeatureVectorEnhancements1] in
|
|
|
|
def SelectVR128 : SelectWrapper<f128, VR128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-09-13 07:03:39 +08:00
|
|
|
defm CondStoreF32 : CondStores<FP32, simple_store,
|
|
|
|
simple_load, bdxaddr20only>;
|
|
|
|
defm CondStoreF64 : CondStores<FP64, simple_store,
|
|
|
|
simple_load, bdxaddr20only>;
|
2013-06-27 17:27:40 +08:00
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Move instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Load zero.
|
2017-12-05 19:24:39 +08:00
|
|
|
let isAsCheapAsAMove = 1, isMoveImm = 1 in {
|
2016-11-09 02:37:48 +08:00
|
|
|
def LZER : InherentRRE<"lzer", 0xB374, FP32, fpimm0>;
|
|
|
|
def LZDR : InherentRRE<"lzdr", 0xB375, FP64, fpimm0>;
|
|
|
|
def LZXR : InherentRRE<"lzxr", 0xB376, FP128, fpimm0>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Moves between two floating-point registers.
|
2017-12-05 19:24:39 +08:00
|
|
|
def LER : UnaryRR <"ler", 0x38, null_frag, FP32, FP32>;
|
|
|
|
def LDR : UnaryRR <"ldr", 0x28, null_frag, FP64, FP64>;
|
|
|
|
def LXR : UnaryRRE<"lxr", 0xB365, null_frag, FP128, FP128>;
|
2016-03-14 21:50:03 +08:00
|
|
|
|
2017-12-05 19:24:39 +08:00
|
|
|
// For z13 we prefer LDR over LER to avoid partial register dependencies.
|
|
|
|
let isCodeGenOnly = 1 in
|
|
|
|
def LDR32 : UnaryRR<"ldr", 0x28, null_frag, FP32, FP32>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2013-08-07 19:03:34 +08:00
|
|
|
// Moves between two floating-point registers that also set the condition
|
|
|
|
// codes.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1,
|
|
|
|
Defs = [CC], CCValues = 0xF, CompareZeroCCMask = 0xF in {
|
2016-11-09 02:36:31 +08:00
|
|
|
defm LTEBR : LoadAndTestRRE<"ltebr", 0xB302, FP32>;
|
|
|
|
defm LTDBR : LoadAndTestRRE<"ltdbr", 0xB312, FP64>;
|
|
|
|
defm LTXBR : LoadAndTestRRE<"ltxbr", 0xB342, FP128>;
|
2013-08-07 19:03:34 +08:00
|
|
|
}
|
2015-10-08 15:40:16 +08:00
|
|
|
// Note that LTxBRCompare is not available if we have vector support,
|
|
|
|
// since load-and-test instructions will partially clobber the target
|
|
|
|
// (vector) register.
|
2015-05-06 03:28:34 +08:00
|
|
|
let Predicates = [FeatureNoVector] in {
|
|
|
|
defm : CompareZeroFP<LTEBRCompare, FP32>;
|
|
|
|
defm : CompareZeroFP<LTDBRCompare, FP64>;
|
|
|
|
defm : CompareZeroFP<LTXBRCompare, FP128>;
|
|
|
|
}
|
2013-08-07 19:03:34 +08:00
|
|
|
|
2015-10-08 15:40:16 +08:00
|
|
|
// Use a normal load-and-test for compare against zero in case of
|
|
|
|
// vector support (via a pseudo to simplify instruction selection).
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1,
|
|
|
|
Defs = [CC], usesCustomInserter = 1, hasNoSchedulingInfo = 1 in {
|
2015-10-08 15:40:16 +08:00
|
|
|
def LTEBRCompare_VecPseudo : Pseudo<(outs), (ins FP32:$R1, FP32:$R2), []>;
|
|
|
|
def LTDBRCompare_VecPseudo : Pseudo<(outs), (ins FP64:$R1, FP64:$R2), []>;
|
|
|
|
def LTXBRCompare_VecPseudo : Pseudo<(outs), (ins FP128:$R1, FP128:$R2), []>;
|
|
|
|
}
|
|
|
|
let Predicates = [FeatureVector] in {
|
|
|
|
defm : CompareZeroFP<LTEBRCompare_VecPseudo, FP32>;
|
|
|
|
defm : CompareZeroFP<LTDBRCompare_VecPseudo, FP64>;
|
|
|
|
}
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureVector, FeatureNoVectorEnhancements1] in
|
|
|
|
defm : CompareZeroFP<LTXBRCompare_VecPseudo, FP128>;
|
2015-10-08 15:40:16 +08:00
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
// Moves between 64-bit integer and floating-point registers.
|
2016-11-09 02:36:31 +08:00
|
|
|
def LGDR : UnaryRRE<"lgdr", 0xB3CD, bitconvert, GR64, FP64>;
|
|
|
|
def LDGR : UnaryRRE<"ldgr", 0xB3C1, bitconvert, FP64, GR64>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// fcopysign with an FP32 result.
|
|
|
|
let isCodeGenOnly = 1 in {
|
2016-11-09 02:36:31 +08:00
|
|
|
def CPSDRss : BinaryRRFb<"cpsdr", 0xB372, fcopysign, FP32, FP32, FP32>;
|
|
|
|
def CPSDRsd : BinaryRRFb<"cpsdr", 0xB372, fcopysign, FP32, FP32, FP64>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
2013-05-14 17:28:21 +08:00
|
|
|
// The sign of an FP128 is in the high register.
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in
|
|
|
|
def : Pat<(fcopysign FP32:$src1, (f32 (fpround (f128 FP128:$src2)))),
|
|
|
|
(CPSDRsd FP32:$src1, (EXTRACT_SUBREG FP128:$src2, subreg_h64))>;
|
|
|
|
let Predicates = [FeatureVectorEnhancements1] in
|
|
|
|
def : Pat<(fcopysign FP32:$src1, (f32 (fpround (f128 VR128:$src2)))),
|
2018-08-15 23:21:23 +08:00
|
|
|
(CPSDRsd FP32:$src1, (EXTRACT_SUBREG VR128:$src2, subreg_h64))>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// fcopysign with an FP64 result.
|
|
|
|
let isCodeGenOnly = 1 in
|
2016-11-09 02:36:31 +08:00
|
|
|
def CPSDRds : BinaryRRFb<"cpsdr", 0xB372, fcopysign, FP64, FP64, FP32>;
|
|
|
|
def CPSDRdd : BinaryRRFb<"cpsdr", 0xB372, fcopysign, FP64, FP64, FP64>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2013-05-14 17:28:21 +08:00
|
|
|
// The sign of an FP128 is in the high register.
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in
|
|
|
|
def : Pat<(fcopysign FP64:$src1, (f64 (fpround (f128 FP128:$src2)))),
|
|
|
|
(CPSDRdd FP64:$src1, (EXTRACT_SUBREG FP128:$src2, subreg_h64))>;
|
|
|
|
let Predicates = [FeatureVectorEnhancements1] in
|
|
|
|
def : Pat<(fcopysign FP64:$src1, (f64 (fpround (f128 VR128:$src2)))),
|
2018-08-15 23:21:23 +08:00
|
|
|
(CPSDRdd FP64:$src1, (EXTRACT_SUBREG VR128:$src2, subreg_h64))>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// fcopysign with an FP128 result. Use "upper" as the high half and leave
|
|
|
|
// the low half as-is.
|
|
|
|
class CopySign128<RegisterOperand cls, dag upper>
|
|
|
|
: Pat<(fcopysign FP128:$src1, cls:$src2),
|
2013-09-30 18:28:35 +08:00
|
|
|
(INSERT_SUBREG FP128:$src1, upper, subreg_h64)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in {
|
|
|
|
def : CopySign128<FP32, (CPSDRds (EXTRACT_SUBREG FP128:$src1, subreg_h64),
|
|
|
|
FP32:$src2)>;
|
|
|
|
def : CopySign128<FP64, (CPSDRdd (EXTRACT_SUBREG FP128:$src1, subreg_h64),
|
|
|
|
FP64:$src2)>;
|
|
|
|
def : CopySign128<FP128, (CPSDRdd (EXTRACT_SUBREG FP128:$src1, subreg_h64),
|
|
|
|
(EXTRACT_SUBREG FP128:$src2, subreg_h64))>;
|
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2013-09-05 18:36:45 +08:00
|
|
|
defm LoadStoreF32 : MVCLoadStore<load, f32, MVCSequence, 4>;
|
|
|
|
defm LoadStoreF64 : MVCLoadStore<load, f64, MVCSequence, 8>;
|
|
|
|
defm LoadStoreF128 : MVCLoadStore<load, f128, MVCSequence, 16>;
|
2013-07-09 17:46:39 +08:00
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Load instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-12-05 19:24:39 +08:00
|
|
|
let canFoldAsLoad = 1, SimpleBDXLoad = 1, mayLoad = 1 in {
|
2013-07-03 18:10:02 +08:00
|
|
|
defm LE : UnaryRXPair<"le", 0x78, 0xED64, load, FP32, 4>;
|
|
|
|
defm LD : UnaryRXPair<"ld", 0x68, 0xED65, load, FP64, 8>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2015-05-06 03:28:34 +08:00
|
|
|
// For z13 we prefer LDE over LE to avoid partial register dependencies.
|
2017-05-30 18:13:23 +08:00
|
|
|
let isCodeGenOnly = 1 in
|
|
|
|
def LDE32 : UnaryRXE<"lde", 0xED24, null_frag, FP32, 4>;
|
2015-05-06 03:28:34 +08:00
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
// These instructions are split after register allocation, so we don't
|
|
|
|
// want a custom inserter.
|
|
|
|
let Has20BitOffset = 1, HasIndex = 1, Is128Bit = 1 in {
|
|
|
|
def LX : Pseudo<(outs FP128:$dst), (ins bdxaddr20only128:$src),
|
|
|
|
[(set FP128:$dst, (load bdxaddr20only128:$src))]>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Store instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2017-12-05 19:24:39 +08:00
|
|
|
let SimpleBDXStore = 1, mayStore = 1 in {
|
2013-07-03 18:10:02 +08:00
|
|
|
defm STE : StoreRXPair<"ste", 0x70, 0xED66, store, FP32, 4>;
|
|
|
|
defm STD : StoreRXPair<"std", 0x60, 0xED67, store, FP64, 8>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// These instructions are split after register allocation, so we don't
|
|
|
|
// want a custom inserter.
|
|
|
|
let Has20BitOffset = 1, HasIndex = 1, Is128Bit = 1 in {
|
|
|
|
def STX : Pseudo<(outs), (ins FP128:$src, bdxaddr20only128:$dst),
|
|
|
|
[(store FP128:$src, bdxaddr20only128:$dst)]>;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Conversion instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Convert floating-point values to narrower representations, rounding
|
|
|
|
// according to the current mode. The destination of LEXBR and LDXBR
|
|
|
|
// is a 128-bit value, but only the first register of the pair is used.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
|
|
|
def LEDBR : UnaryRRE<"ledbr", 0xB344, any_fpround, FP32, FP64>;
|
2019-05-13 17:47:26 +08:00
|
|
|
def LEXBR : UnaryRRE<"lexbr", 0xB346, null_frag, FP128, FP128>;
|
|
|
|
def LDXBR : UnaryRRE<"ldxbr", 0xB345, null_frag, FP128, FP128>;
|
|
|
|
|
|
|
|
def LEDBRA : TernaryRRFe<"ledbra", 0xB344, FP32, FP64>,
|
|
|
|
Requires<[FeatureFPExtension]>;
|
|
|
|
def LEXBRA : TernaryRRFe<"lexbra", 0xB346, FP128, FP128>,
|
|
|
|
Requires<[FeatureFPExtension]>;
|
|
|
|
def LDXBRA : TernaryRRFe<"ldxbra", 0xB345, FP128, FP128>,
|
|
|
|
Requires<[FeatureFPExtension]>;
|
|
|
|
}
|
2014-07-10 19:00:55 +08:00
|
|
|
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in {
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(f32 (any_fpround FP128:$src)),
|
2018-08-15 23:21:23 +08:00
|
|
|
(EXTRACT_SUBREG (LEXBR FP128:$src), subreg_hh32)>;
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(f64 (any_fpround FP128:$src)),
|
2017-07-18 01:44:20 +08:00
|
|
|
(EXTRACT_SUBREG (LDXBR FP128:$src), subreg_h64)>;
|
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Extend register floating-point values to wider representations.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
|
|
|
def LDEBR : UnaryRRE<"ldebr", 0xB304, any_fpextend, FP64, FP32>;
|
2019-05-13 17:47:26 +08:00
|
|
|
def LXEBR : UnaryRRE<"lxebr", 0xB306, null_frag, FP128, FP32>;
|
|
|
|
def LXDBR : UnaryRRE<"lxdbr", 0xB305, null_frag, FP128, FP64>;
|
|
|
|
}
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in {
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(f128 (any_fpextend (f32 FP32:$src))), (LXEBR FP32:$src)>;
|
|
|
|
def : Pat<(f128 (any_fpextend (f64 FP64:$src))), (LXDBR FP64:$src)>;
|
2017-07-18 01:44:20 +08:00
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Extend memory floating-point values to wider representations.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
2019-06-27 01:19:12 +08:00
|
|
|
def LDEB : UnaryRXE<"ldeb", 0xED04, any_extloadf32, FP64, 4>;
|
|
|
|
def LXEB : UnaryRXE<"lxeb", 0xED06, null_frag, FP128, 4>;
|
|
|
|
def LXDB : UnaryRXE<"lxdb", 0xED05, null_frag, FP128, 8>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in {
|
2019-06-27 01:19:12 +08:00
|
|
|
def : Pat<(f128 (any_extloadf32 bdxaddr12only:$src)),
|
2017-07-18 01:44:20 +08:00
|
|
|
(LXEB bdxaddr12only:$src)>;
|
2019-06-27 01:19:12 +08:00
|
|
|
def : Pat<(f128 (any_extloadf64 bdxaddr12only:$src)),
|
2017-07-18 01:44:20 +08:00
|
|
|
(LXDB bdxaddr12only:$src)>;
|
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Convert a signed integer register value to a floating-point one.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
2019-12-18 01:20:14 +08:00
|
|
|
def CEFBR : UnaryRRE<"cefbr", 0xB394, any_sint_to_fp, FP32, GR32>;
|
|
|
|
def CDFBR : UnaryRRE<"cdfbr", 0xB395, any_sint_to_fp, FP64, GR32>;
|
|
|
|
def CXFBR : UnaryRRE<"cxfbr", 0xB396, any_sint_to_fp, FP128, GR32>;
|
2019-05-13 17:47:26 +08:00
|
|
|
|
2019-12-18 01:20:14 +08:00
|
|
|
def CEGBR : UnaryRRE<"cegbr", 0xB3A4, any_sint_to_fp, FP32, GR64>;
|
|
|
|
def CDGBR : UnaryRRE<"cdgbr", 0xB3A5, any_sint_to_fp, FP64, GR64>;
|
|
|
|
def CXGBR : UnaryRRE<"cxgbr", 0xB3A6, any_sint_to_fp, FP128, GR64>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2016-11-09 04:18:41 +08:00
|
|
|
// The FP extension feature provides versions of the above that allow
|
|
|
|
// specifying rounding mode and inexact-exception suppression flags.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1, Predicates = [FeatureFPExtension] in {
|
2016-11-09 04:18:41 +08:00
|
|
|
def CEFBRA : TernaryRRFe<"cefbra", 0xB394, FP32, GR32>;
|
|
|
|
def CDFBRA : TernaryRRFe<"cdfbra", 0xB395, FP64, GR32>;
|
|
|
|
def CXFBRA : TernaryRRFe<"cxfbra", 0xB396, FP128, GR32>;
|
|
|
|
|
|
|
|
def CEGBRA : TernaryRRFe<"cegbra", 0xB3A4, FP32, GR64>;
|
|
|
|
def CDGBRA : TernaryRRFe<"cdgbra", 0xB3A5, FP64, GR64>;
|
|
|
|
def CXGBRA : TernaryRRFe<"cxgbra", 0xB3A6, FP128, GR64>;
|
|
|
|
}
|
|
|
|
|
2014-03-21 18:56:30 +08:00
|
|
|
// Convert am unsigned integer register value to a floating-point one.
|
|
|
|
let Predicates = [FeatureFPExtension] in {
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
2019-05-13 17:47:26 +08:00
|
|
|
def CELFBR : TernaryRRFe<"celfbr", 0xB390, FP32, GR32>;
|
|
|
|
def CDLFBR : TernaryRRFe<"cdlfbr", 0xB391, FP64, GR32>;
|
|
|
|
def CXLFBR : TernaryRRFe<"cxlfbr", 0xB392, FP128, GR32>;
|
|
|
|
|
|
|
|
def CELGBR : TernaryRRFe<"celgbr", 0xB3A0, FP32, GR64>;
|
|
|
|
def CDLGBR : TernaryRRFe<"cdlgbr", 0xB3A1, FP64, GR64>;
|
|
|
|
def CXLGBR : TernaryRRFe<"cxlgbr", 0xB3A2, FP128, GR64>;
|
|
|
|
}
|
2014-03-21 18:56:30 +08:00
|
|
|
|
2019-12-18 01:20:14 +08:00
|
|
|
def : Pat<(f32 (any_uint_to_fp GR32:$src)), (CELFBR 0, GR32:$src, 0)>;
|
|
|
|
def : Pat<(f64 (any_uint_to_fp GR32:$src)), (CDLFBR 0, GR32:$src, 0)>;
|
|
|
|
def : Pat<(f128 (any_uint_to_fp GR32:$src)), (CXLFBR 0, GR32:$src, 0)>;
|
2014-03-21 18:56:30 +08:00
|
|
|
|
2019-12-18 01:20:14 +08:00
|
|
|
def : Pat<(f32 (any_uint_to_fp GR64:$src)), (CELGBR 0, GR64:$src, 0)>;
|
|
|
|
def : Pat<(f64 (any_uint_to_fp GR64:$src)), (CDLGBR 0, GR64:$src, 0)>;
|
|
|
|
def : Pat<(f128 (any_uint_to_fp GR64:$src)), (CXLGBR 0, GR64:$src, 0)>;
|
2014-03-21 18:56:30 +08:00
|
|
|
}
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
// Convert a floating-point register value to a signed integer value,
|
|
|
|
// with the second operand (modifier M3) specifying the rounding mode.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1, Defs = [CC] in {
|
2016-11-09 02:36:31 +08:00
|
|
|
def CFEBR : BinaryRRFe<"cfebr", 0xB398, GR32, FP32>;
|
|
|
|
def CFDBR : BinaryRRFe<"cfdbr", 0xB399, GR32, FP64>;
|
|
|
|
def CFXBR : BinaryRRFe<"cfxbr", 0xB39A, GR32, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2016-11-09 02:36:31 +08:00
|
|
|
def CGEBR : BinaryRRFe<"cgebr", 0xB3A8, GR64, FP32>;
|
|
|
|
def CGDBR : BinaryRRFe<"cgdbr", 0xB3A9, GR64, FP64>;
|
|
|
|
def CGXBR : BinaryRRFe<"cgxbr", 0xB3AA, GR64, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// fp_to_sint always rounds towards zero, which is modifier value 5.
|
2019-09-03 00:49:29 +08:00
|
|
|
def : Pat<(i32 (any_fp_to_sint FP32:$src)), (CFEBR 5, FP32:$src)>;
|
|
|
|
def : Pat<(i32 (any_fp_to_sint FP64:$src)), (CFDBR 5, FP64:$src)>;
|
|
|
|
def : Pat<(i32 (any_fp_to_sint FP128:$src)), (CFXBR 5, FP128:$src)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-09-03 00:49:29 +08:00
|
|
|
def : Pat<(i64 (any_fp_to_sint FP32:$src)), (CGEBR 5, FP32:$src)>;
|
|
|
|
def : Pat<(i64 (any_fp_to_sint FP64:$src)), (CGDBR 5, FP64:$src)>;
|
|
|
|
def : Pat<(i64 (any_fp_to_sint FP128:$src)), (CGXBR 5, FP128:$src)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2016-11-09 04:18:41 +08:00
|
|
|
// The FP extension feature provides versions of the above that allow
|
|
|
|
// also specifying the inexact-exception suppression flag.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1,
|
|
|
|
Predicates = [FeatureFPExtension], Defs = [CC] in {
|
2016-11-09 04:18:41 +08:00
|
|
|
def CFEBRA : TernaryRRFe<"cfebra", 0xB398, GR32, FP32>;
|
|
|
|
def CFDBRA : TernaryRRFe<"cfdbra", 0xB399, GR32, FP64>;
|
|
|
|
def CFXBRA : TernaryRRFe<"cfxbra", 0xB39A, GR32, FP128>;
|
|
|
|
|
|
|
|
def CGEBRA : TernaryRRFe<"cgebra", 0xB3A8, GR64, FP32>;
|
|
|
|
def CGDBRA : TernaryRRFe<"cgdbra", 0xB3A9, GR64, FP64>;
|
|
|
|
def CGXBRA : TernaryRRFe<"cgxbra", 0xB3AA, GR64, FP128>;
|
|
|
|
}
|
|
|
|
|
2014-03-21 18:56:30 +08:00
|
|
|
// Convert a floating-point register value to an unsigned integer value.
|
|
|
|
let Predicates = [FeatureFPExtension] in {
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1, Defs = [CC] in {
|
2016-11-09 02:36:31 +08:00
|
|
|
def CLFEBR : TernaryRRFe<"clfebr", 0xB39C, GR32, FP32>;
|
|
|
|
def CLFDBR : TernaryRRFe<"clfdbr", 0xB39D, GR32, FP64>;
|
|
|
|
def CLFXBR : TernaryRRFe<"clfxbr", 0xB39E, GR32, FP128>;
|
2014-03-21 18:56:30 +08:00
|
|
|
|
2016-11-09 02:36:31 +08:00
|
|
|
def CLGEBR : TernaryRRFe<"clgebr", 0xB3AC, GR64, FP32>;
|
|
|
|
def CLGDBR : TernaryRRFe<"clgdbr", 0xB3AD, GR64, FP64>;
|
|
|
|
def CLGXBR : TernaryRRFe<"clgxbr", 0xB3AE, GR64, FP128>;
|
2014-03-21 18:56:30 +08:00
|
|
|
}
|
|
|
|
|
2019-09-03 00:49:29 +08:00
|
|
|
def : Pat<(i32 (any_fp_to_uint FP32:$src)), (CLFEBR 5, FP32:$src, 0)>;
|
|
|
|
def : Pat<(i32 (any_fp_to_uint FP64:$src)), (CLFDBR 5, FP64:$src, 0)>;
|
|
|
|
def : Pat<(i32 (any_fp_to_uint FP128:$src)), (CLFXBR 5, FP128:$src, 0)>;
|
2014-03-21 18:56:30 +08:00
|
|
|
|
2019-09-03 00:49:29 +08:00
|
|
|
def : Pat<(i64 (any_fp_to_uint FP32:$src)), (CLGEBR 5, FP32:$src, 0)>;
|
|
|
|
def : Pat<(i64 (any_fp_to_uint FP64:$src)), (CLGDBR 5, FP64:$src, 0)>;
|
|
|
|
def : Pat<(i64 (any_fp_to_uint FP128:$src)), (CLGXBR 5, FP128:$src, 0)>;
|
2014-03-21 18:56:30 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Unary arithmetic
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-10-02 02:12:28 +08:00
|
|
|
// We prefer generic instructions during isel, because they do not
|
|
|
|
// clobber CC and therefore give the scheduler more freedom. In cases
|
|
|
|
// the CC is actually useful, the SystemZElimCompare pass will try to
|
|
|
|
// convert generic instructions into opcodes that also set CC. Note
|
|
|
|
// that lcdf / lpdf / lndf only affect the sign bit, and can therefore
|
|
|
|
// be used with fp32 as well. This could be done for fp128, in which
|
|
|
|
// case the operands would have to be tied.
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
// Negation (Load Complement).
|
2013-08-07 19:10:06 +08:00
|
|
|
let Defs = [CC], CCValues = 0xF, CompareZeroCCMask = 0xF in {
|
2016-11-09 02:36:31 +08:00
|
|
|
def LCEBR : UnaryRRE<"lcebr", 0xB303, null_frag, FP32, FP32>;
|
|
|
|
def LCDBR : UnaryRRE<"lcdbr", 0xB313, null_frag, FP64, FP64>;
|
|
|
|
def LCXBR : UnaryRRE<"lcxbr", 0xB343, fneg, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
2015-10-02 02:12:28 +08:00
|
|
|
// Generic form, which does not set CC.
|
2016-11-09 02:36:31 +08:00
|
|
|
def LCDFR : UnaryRRE<"lcdfr", 0xB373, fneg, FP64, FP64>;
|
2015-10-02 02:12:28 +08:00
|
|
|
let isCodeGenOnly = 1 in
|
2016-11-09 02:36:31 +08:00
|
|
|
def LCDFR_32 : UnaryRRE<"lcdfr", 0xB373, fneg, FP32, FP32>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Absolute value (Load Positive).
|
2013-08-07 19:10:06 +08:00
|
|
|
let Defs = [CC], CCValues = 0xF, CompareZeroCCMask = 0xF in {
|
2016-11-09 02:36:31 +08:00
|
|
|
def LPEBR : UnaryRRE<"lpebr", 0xB300, null_frag, FP32, FP32>;
|
|
|
|
def LPDBR : UnaryRRE<"lpdbr", 0xB310, null_frag, FP64, FP64>;
|
|
|
|
def LPXBR : UnaryRRE<"lpxbr", 0xB340, fabs, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
2015-10-02 02:12:28 +08:00
|
|
|
// Generic form, which does not set CC.
|
2016-11-09 02:36:31 +08:00
|
|
|
def LPDFR : UnaryRRE<"lpdfr", 0xB370, fabs, FP64, FP64>;
|
2015-10-02 02:12:28 +08:00
|
|
|
let isCodeGenOnly = 1 in
|
2016-11-09 02:36:31 +08:00
|
|
|
def LPDFR_32 : UnaryRRE<"lpdfr", 0xB370, fabs, FP32, FP32>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Negative absolute value (Load Negative).
|
2013-08-07 19:10:06 +08:00
|
|
|
let Defs = [CC], CCValues = 0xF, CompareZeroCCMask = 0xF in {
|
2016-11-09 02:36:31 +08:00
|
|
|
def LNEBR : UnaryRRE<"lnebr", 0xB301, null_frag, FP32, FP32>;
|
|
|
|
def LNDBR : UnaryRRE<"lndbr", 0xB311, null_frag, FP64, FP64>;
|
|
|
|
def LNXBR : UnaryRRE<"lnxbr", 0xB341, fnabs, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
2015-10-02 02:12:28 +08:00
|
|
|
// Generic form, which does not set CC.
|
2016-11-09 02:36:31 +08:00
|
|
|
def LNDFR : UnaryRRE<"lndfr", 0xB371, fnabs, FP64, FP64>;
|
2015-10-02 02:12:28 +08:00
|
|
|
let isCodeGenOnly = 1 in
|
2016-11-09 02:36:31 +08:00
|
|
|
def LNDFR_32 : UnaryRRE<"lndfr", 0xB371, fnabs, FP32, FP32>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Square root.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
|
|
|
def SQEBR : UnaryRRE<"sqebr", 0xB314, any_fsqrt, FP32, FP32>;
|
|
|
|
def SQDBR : UnaryRRE<"sqdbr", 0xB315, any_fsqrt, FP64, FP64>;
|
|
|
|
def SQXBR : UnaryRRE<"sqxbr", 0xB316, any_fsqrt, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
def SQEB : UnaryRXE<"sqeb", 0xED14, loadu<any_fsqrt>, FP32, 4>;
|
|
|
|
def SQDB : UnaryRXE<"sqdb", 0xED15, loadu<any_fsqrt>, FP64, 8>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Round to an integer, with the second operand (modifier M3) specifying
|
2013-08-21 16:58:08 +08:00
|
|
|
// the rounding mode. These forms always check for inexact conditions.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
2019-05-13 17:47:26 +08:00
|
|
|
def FIEBR : BinaryRRFe<"fiebr", 0xB357, FP32, FP32>;
|
|
|
|
def FIDBR : BinaryRRFe<"fidbr", 0xB35F, FP64, FP64>;
|
|
|
|
def FIXBR : BinaryRRFe<"fixbr", 0xB347, FP128, FP128>;
|
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// frint rounds according to the current mode (modifier 0) and detects
|
|
|
|
// inexact conditions.
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(any_frint FP32:$src), (FIEBR 0, FP32:$src)>;
|
|
|
|
def : Pat<(any_frint FP64:$src), (FIDBR 0, FP64:$src)>;
|
|
|
|
def : Pat<(any_frint FP128:$src), (FIXBR 0, FP128:$src)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2013-08-21 17:04:20 +08:00
|
|
|
let Predicates = [FeatureFPExtension] in {
|
2014-03-21 19:04:54 +08:00
|
|
|
// Extended forms of the FIxBR instructions. M4 can be set to 4
|
|
|
|
// to suppress detection of inexact conditions.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
2019-05-13 17:47:26 +08:00
|
|
|
def FIEBRA : TernaryRRFe<"fiebra", 0xB357, FP32, FP32>;
|
|
|
|
def FIDBRA : TernaryRRFe<"fidbra", 0xB35F, FP64, FP64>;
|
|
|
|
def FIXBRA : TernaryRRFe<"fixbra", 0xB347, FP128, FP128>;
|
|
|
|
}
|
2014-03-21 19:04:54 +08:00
|
|
|
|
2013-08-21 17:04:20 +08:00
|
|
|
// fnearbyint is like frint but does not detect inexact conditions.
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(any_fnearbyint FP32:$src), (FIEBRA 0, FP32:$src, 4)>;
|
|
|
|
def : Pat<(any_fnearbyint FP64:$src), (FIDBRA 0, FP64:$src, 4)>;
|
|
|
|
def : Pat<(any_fnearbyint FP128:$src), (FIXBRA 0, FP128:$src, 4)>;
|
2013-08-21 17:04:20 +08:00
|
|
|
|
|
|
|
// floor is no longer allowed to raise an inexact condition,
|
|
|
|
// so restrict it to the cases where the condition can be suppressed.
|
|
|
|
// Mode 7 is round towards -inf.
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(any_ffloor FP32:$src), (FIEBRA 7, FP32:$src, 4)>;
|
|
|
|
def : Pat<(any_ffloor FP64:$src), (FIDBRA 7, FP64:$src, 4)>;
|
|
|
|
def : Pat<(any_ffloor FP128:$src), (FIXBRA 7, FP128:$src, 4)>;
|
2013-08-21 17:04:20 +08:00
|
|
|
|
|
|
|
// Same idea for ceil, where mode 6 is round towards +inf.
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(any_fceil FP32:$src), (FIEBRA 6, FP32:$src, 4)>;
|
|
|
|
def : Pat<(any_fceil FP64:$src), (FIDBRA 6, FP64:$src, 4)>;
|
|
|
|
def : Pat<(any_fceil FP128:$src), (FIXBRA 6, FP128:$src, 4)>;
|
2013-08-21 17:04:20 +08:00
|
|
|
|
|
|
|
// Same idea for trunc, where mode 5 is round towards zero.
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(any_ftrunc FP32:$src), (FIEBRA 5, FP32:$src, 4)>;
|
|
|
|
def : Pat<(any_ftrunc FP64:$src), (FIDBRA 5, FP64:$src, 4)>;
|
|
|
|
def : Pat<(any_ftrunc FP128:$src), (FIXBRA 5, FP128:$src, 4)>;
|
2013-08-21 17:04:20 +08:00
|
|
|
|
|
|
|
// Same idea for round, where mode 1 is round towards nearest with
|
|
|
|
// ties away from zero.
|
2019-06-06 06:33:10 +08:00
|
|
|
def : Pat<(any_fround FP32:$src), (FIEBRA 1, FP32:$src, 4)>;
|
|
|
|
def : Pat<(any_fround FP64:$src), (FIDBRA 1, FP64:$src, 4)>;
|
|
|
|
def : Pat<(any_fround FP128:$src), (FIXBRA 1, FP128:$src, 4)>;
|
2013-08-21 17:04:20 +08:00
|
|
|
}
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Binary arithmetic
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
// Addition.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1,
|
|
|
|
Defs = [CC], CCValues = 0xF, CompareZeroCCMask = 0xF in {
|
2013-05-07 00:15:19 +08:00
|
|
|
let isCommutable = 1 in {
|
2019-06-06 06:33:10 +08:00
|
|
|
def AEBR : BinaryRRE<"aebr", 0xB30A, any_fadd, FP32, FP32>;
|
|
|
|
def ADBR : BinaryRRE<"adbr", 0xB31A, any_fadd, FP64, FP64>;
|
|
|
|
def AXBR : BinaryRRE<"axbr", 0xB34A, any_fadd, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
2019-06-06 06:33:10 +08:00
|
|
|
def AEB : BinaryRXE<"aeb", 0xED0A, any_fadd, FP32, load, 4>;
|
|
|
|
def ADB : BinaryRXE<"adb", 0xED1A, any_fadd, FP64, load, 8>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Subtraction.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1,
|
|
|
|
Defs = [CC], CCValues = 0xF, CompareZeroCCMask = 0xF in {
|
|
|
|
def SEBR : BinaryRRE<"sebr", 0xB30B, any_fsub, FP32, FP32>;
|
|
|
|
def SDBR : BinaryRRE<"sdbr", 0xB31B, any_fsub, FP64, FP64>;
|
|
|
|
def SXBR : BinaryRRE<"sxbr", 0xB34B, any_fsub, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
def SEB : BinaryRXE<"seb", 0xED0B, any_fsub, FP32, load, 4>;
|
|
|
|
def SDB : BinaryRXE<"sdb", 0xED1B, any_fsub, FP64, load, 8>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// Multiplication.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
2019-05-13 17:47:26 +08:00
|
|
|
let isCommutable = 1 in {
|
2019-06-06 06:33:10 +08:00
|
|
|
def MEEBR : BinaryRRE<"meebr", 0xB317, any_fmul, FP32, FP32>;
|
|
|
|
def MDBR : BinaryRRE<"mdbr", 0xB31C, any_fmul, FP64, FP64>;
|
|
|
|
def MXBR : BinaryRRE<"mxbr", 0xB34C, any_fmul, FP128, FP128>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2019-06-06 06:33:10 +08:00
|
|
|
def MEEB : BinaryRXE<"meeb", 0xED17, any_fmul, FP32, load, 4>;
|
|
|
|
def MDB : BinaryRXE<"mdb", 0xED1C, any_fmul, FP64, load, 8>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
// f64 multiplication of two FP32 registers.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in
|
2019-05-13 17:47:26 +08:00
|
|
|
def MDEBR : BinaryRRE<"mdebr", 0xB30C, null_frag, FP64, FP32>;
|
[FPEnv][SelectionDAG] Relax chain requirements
This patch implements the following changes:
1) SelectionDAGBuilder::visitConstrainedFPIntrinsic currently treats
each constrained intrinsic like a global barrier (e.g. a function call)
and fully serializes all pending chains. This is actually not required;
it is allowed for constrained intrinsics to be reordered w.r.t one
another or (nonvolatile) memory accesses. The MI-level scheduler already
allows for that flexibility, so it makes sense to allow it at the DAG
level as well.
This patch therefore changes the way chains for constrained intrisincs
are created, and handles them basically like load operations are handled.
This has the effect that constrained intrinsics are no longer serialized
against one another or (nonvolatile) loads. They are still serialized
against stores, but that seems hard to change with the current DAG chain
setup, and it also doesn't seem to be a big problem preventing DAG
2) The OPC_CheckFoldableChainNode check requires that each of the
intermediate nodes in a multi-node pattern match only has a single use.
This check tends to fail if those intermediate nodes are strict operations
as those have a chain output that typically indeed has another use.
However, we don't really need to consider chains here at all, since they
will all be rewritten anyway by UpdateChains later. Other parts of the
matcher therefore already ignore chains, but this hasOneUse check doesn't.
This patch replaces hasOneUse by a custom test that verifies there is no
more than one use of any non-chain output value.
In theory, this change could affect code unrelated to strict FP nodes,
but at least on SystemZ I could not find any single instance of that
happening
3) The SystemZ back-end currently does not allow matching multiply-and-
extend operations (32x32 -> 64bit or 64x64 -> 128bit FP multiply) for
strict FP operations. This was not possible in the past due to the
problems described under 1) and 2) above.
With those issues fixed, it is now possible to fully support those
instructions in strict mode as well, and this patch does so.
Differential Revision: https://reviews.llvm.org/D70913
2019-12-06 18:02:11 +08:00
|
|
|
def : Pat<(any_fmul (f64 (any_fpextend FP32:$src1)),
|
|
|
|
(f64 (any_fpextend FP32:$src2))),
|
2013-05-07 00:15:19 +08:00
|
|
|
(MDEBR (INSERT_SUBREG (f64 (IMPLICIT_DEF)),
|
2018-08-15 23:21:23 +08:00
|
|
|
FP32:$src1, subreg_h32), FP32:$src2)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// f64 multiplication of an FP32 register and an f32 memory.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in
|
2019-05-13 17:47:26 +08:00
|
|
|
def MDEB : BinaryRXE<"mdeb", 0xED0C, null_frag, FP64, load, 4>;
|
[FPEnv][SelectionDAG] Relax chain requirements
This patch implements the following changes:
1) SelectionDAGBuilder::visitConstrainedFPIntrinsic currently treats
each constrained intrinsic like a global barrier (e.g. a function call)
and fully serializes all pending chains. This is actually not required;
it is allowed for constrained intrinsics to be reordered w.r.t one
another or (nonvolatile) memory accesses. The MI-level scheduler already
allows for that flexibility, so it makes sense to allow it at the DAG
level as well.
This patch therefore changes the way chains for constrained intrisincs
are created, and handles them basically like load operations are handled.
This has the effect that constrained intrinsics are no longer serialized
against one another or (nonvolatile) loads. They are still serialized
against stores, but that seems hard to change with the current DAG chain
setup, and it also doesn't seem to be a big problem preventing DAG
2) The OPC_CheckFoldableChainNode check requires that each of the
intermediate nodes in a multi-node pattern match only has a single use.
This check tends to fail if those intermediate nodes are strict operations
as those have a chain output that typically indeed has another use.
However, we don't really need to consider chains here at all, since they
will all be rewritten anyway by UpdateChains later. Other parts of the
matcher therefore already ignore chains, but this hasOneUse check doesn't.
This patch replaces hasOneUse by a custom test that verifies there is no
more than one use of any non-chain output value.
In theory, this change could affect code unrelated to strict FP nodes,
but at least on SystemZ I could not find any single instance of that
happening
3) The SystemZ back-end currently does not allow matching multiply-and-
extend operations (32x32 -> 64bit or 64x64 -> 128bit FP multiply) for
strict FP operations. This was not possible in the past due to the
problems described under 1) and 2) above.
With those issues fixed, it is now possible to fully support those
instructions in strict mode as well, and this patch does so.
Differential Revision: https://reviews.llvm.org/D70913
2019-12-06 18:02:11 +08:00
|
|
|
def : Pat<(any_fmul (f64 (any_fpextend FP32:$src1)),
|
|
|
|
(f64 (any_extloadf32 bdxaddr12only:$addr))),
|
2018-08-15 23:21:23 +08:00
|
|
|
(MDEB (INSERT_SUBREG (f64 (IMPLICIT_DEF)), FP32:$src1, subreg_h32),
|
2013-05-07 00:15:19 +08:00
|
|
|
bdxaddr12only:$addr)>;
|
|
|
|
|
|
|
|
// f128 multiplication of two FP64 registers.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in
|
2019-05-13 17:47:26 +08:00
|
|
|
def MXDBR : BinaryRRE<"mxdbr", 0xB307, null_frag, FP128, FP64>;
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in
|
[FPEnv][SelectionDAG] Relax chain requirements
This patch implements the following changes:
1) SelectionDAGBuilder::visitConstrainedFPIntrinsic currently treats
each constrained intrinsic like a global barrier (e.g. a function call)
and fully serializes all pending chains. This is actually not required;
it is allowed for constrained intrinsics to be reordered w.r.t one
another or (nonvolatile) memory accesses. The MI-level scheduler already
allows for that flexibility, so it makes sense to allow it at the DAG
level as well.
This patch therefore changes the way chains for constrained intrisincs
are created, and handles them basically like load operations are handled.
This has the effect that constrained intrinsics are no longer serialized
against one another or (nonvolatile) loads. They are still serialized
against stores, but that seems hard to change with the current DAG chain
setup, and it also doesn't seem to be a big problem preventing DAG
2) The OPC_CheckFoldableChainNode check requires that each of the
intermediate nodes in a multi-node pattern match only has a single use.
This check tends to fail if those intermediate nodes are strict operations
as those have a chain output that typically indeed has another use.
However, we don't really need to consider chains here at all, since they
will all be rewritten anyway by UpdateChains later. Other parts of the
matcher therefore already ignore chains, but this hasOneUse check doesn't.
This patch replaces hasOneUse by a custom test that verifies there is no
more than one use of any non-chain output value.
In theory, this change could affect code unrelated to strict FP nodes,
but at least on SystemZ I could not find any single instance of that
happening
3) The SystemZ back-end currently does not allow matching multiply-and-
extend operations (32x32 -> 64bit or 64x64 -> 128bit FP multiply) for
strict FP operations. This was not possible in the past due to the
problems described under 1) and 2) above.
With those issues fixed, it is now possible to fully support those
instructions in strict mode as well, and this patch does so.
Differential Revision: https://reviews.llvm.org/D70913
2019-12-06 18:02:11 +08:00
|
|
|
def : Pat<(any_fmul (f128 (any_fpextend FP64:$src1)),
|
|
|
|
(f128 (any_fpextend FP64:$src2))),
|
2017-07-18 01:44:20 +08:00
|
|
|
(MXDBR (INSERT_SUBREG (f128 (IMPLICIT_DEF)),
|
|
|
|
FP64:$src1, subreg_h64), FP64:$src2)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// f128 multiplication of an FP64 register and an f64 memory.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in
|
2019-05-13 17:47:26 +08:00
|
|
|
def MXDB : BinaryRXE<"mxdb", 0xED07, null_frag, FP128, load, 8>;
|
2017-07-18 01:44:20 +08:00
|
|
|
let Predicates = [FeatureNoVectorEnhancements1] in
|
[FPEnv][SelectionDAG] Relax chain requirements
This patch implements the following changes:
1) SelectionDAGBuilder::visitConstrainedFPIntrinsic currently treats
each constrained intrinsic like a global barrier (e.g. a function call)
and fully serializes all pending chains. This is actually not required;
it is allowed for constrained intrinsics to be reordered w.r.t one
another or (nonvolatile) memory accesses. The MI-level scheduler already
allows for that flexibility, so it makes sense to allow it at the DAG
level as well.
This patch therefore changes the way chains for constrained intrisincs
are created, and handles them basically like load operations are handled.
This has the effect that constrained intrinsics are no longer serialized
against one another or (nonvolatile) loads. They are still serialized
against stores, but that seems hard to change with the current DAG chain
setup, and it also doesn't seem to be a big problem preventing DAG
2) The OPC_CheckFoldableChainNode check requires that each of the
intermediate nodes in a multi-node pattern match only has a single use.
This check tends to fail if those intermediate nodes are strict operations
as those have a chain output that typically indeed has another use.
However, we don't really need to consider chains here at all, since they
will all be rewritten anyway by UpdateChains later. Other parts of the
matcher therefore already ignore chains, but this hasOneUse check doesn't.
This patch replaces hasOneUse by a custom test that verifies there is no
more than one use of any non-chain output value.
In theory, this change could affect code unrelated to strict FP nodes,
but at least on SystemZ I could not find any single instance of that
happening
3) The SystemZ back-end currently does not allow matching multiply-and-
extend operations (32x32 -> 64bit or 64x64 -> 128bit FP multiply) for
strict FP operations. This was not possible in the past due to the
problems described under 1) and 2) above.
With those issues fixed, it is now possible to fully support those
instructions in strict mode as well, and this patch does so.
Differential Revision: https://reviews.llvm.org/D70913
2019-12-06 18:02:11 +08:00
|
|
|
def : Pat<(any_fmul (f128 (any_fpextend FP64:$src1)),
|
|
|
|
(f128 (any_extloadf64 bdxaddr12only:$addr))),
|
2017-07-18 01:44:20 +08:00
|
|
|
(MXDB (INSERT_SUBREG (f128 (IMPLICIT_DEF)), FP64:$src1, subreg_h64),
|
|
|
|
bdxaddr12only:$addr)>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Fused multiply-add.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
|
|
|
def MAEBR : TernaryRRD<"maebr", 0xB30E, z_any_fma, FP32, FP32>;
|
|
|
|
def MADBR : TernaryRRD<"madbr", 0xB31E, z_any_fma, FP64, FP64>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
def MAEB : TernaryRXF<"maeb", 0xED0E, z_any_fma, FP32, FP32, load, 4>;
|
|
|
|
def MADB : TernaryRXF<"madb", 0xED1E, z_any_fma, FP64, FP64, load, 8>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Fused multiply-subtract.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
|
|
|
def MSEBR : TernaryRRD<"msebr", 0xB30F, z_any_fms, FP32, FP32>;
|
|
|
|
def MSDBR : TernaryRRD<"msdbr", 0xB31F, z_any_fms, FP64, FP64>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
def MSEB : TernaryRXF<"mseb", 0xED0F, z_any_fms, FP32, FP32, load, 4>;
|
|
|
|
def MSDB : TernaryRXF<"msdb", 0xED1F, z_any_fms, FP64, FP64, load, 8>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
|
|
|
// Division.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1 in {
|
|
|
|
def DEBR : BinaryRRE<"debr", 0xB30D, any_fdiv, FP32, FP32>;
|
|
|
|
def DDBR : BinaryRRE<"ddbr", 0xB31D, any_fdiv, FP64, FP64>;
|
|
|
|
def DXBR : BinaryRRE<"dxbr", 0xB34D, any_fdiv, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
def DEB : BinaryRXE<"deb", 0xED0D, any_fdiv, FP32, load, 4>;
|
|
|
|
def DDB : BinaryRXE<"ddb", 0xED1D, any_fdiv, FP64, load, 8>;
|
2019-05-13 17:47:26 +08:00
|
|
|
}
|
2013-05-07 00:15:19 +08:00
|
|
|
|
2017-05-10 22:18:47 +08:00
|
|
|
// Divide to integer.
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1, Defs = [CC] in {
|
2017-05-10 22:18:47 +08:00
|
|
|
def DIEBR : TernaryRRFb<"diebr", 0xB353, FP32, FP32, FP32>;
|
|
|
|
def DIDBR : TernaryRRFb<"didbr", 0xB35B, FP64, FP64, FP64>;
|
|
|
|
}
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Comparisons
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
let Uses = [FPC], mayRaiseFPException = 1, Defs = [CC], CCValues = 0xF in {
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
def CEBR : CompareRRE<"cebr", 0xB309, z_any_fcmp, FP32, FP32>;
|
|
|
|
def CDBR : CompareRRE<"cdbr", 0xB319, z_any_fcmp, FP64, FP64>;
|
|
|
|
def CXBR : CompareRRE<"cxbr", 0xB349, z_any_fcmp, FP128, FP128>;
|
2013-05-07 00:15:19 +08:00
|
|
|
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
def CEB : CompareRXE<"ceb", 0xED09, z_any_fcmp, FP32, load, 4>;
|
|
|
|
def CDB : CompareRXE<"cdb", 0xED19, z_any_fcmp, FP64, load, 8>;
|
2017-05-10 22:18:47 +08:00
|
|
|
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
def KEBR : CompareRRE<"kebr", 0xB308, z_strict_fcmps, FP32, FP32>;
|
|
|
|
def KDBR : CompareRRE<"kdbr", 0xB318, z_strict_fcmps, FP64, FP64>;
|
|
|
|
def KXBR : CompareRRE<"kxbr", 0xB348, z_strict_fcmps, FP128, FP128>;
|
2017-05-10 22:18:47 +08:00
|
|
|
|
[FPEnv] Constrained FCmp intrinsics
This adds support for constrained floating-point comparison intrinsics.
Specifically, we add:
declare <ty2>
@llvm.experimental.constrained.fcmp(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
declare <ty2>
@llvm.experimental.constrained.fcmps(<type> <op1>, <type> <op2>,
metadata <condition code>,
metadata <exception behavior>)
The first variant implements an IEEE "quiet" comparison (i.e. we only
get an invalid FP exception if either argument is a SNaN), while the
second variant implements an IEEE "signaling" comparison (i.e. we get
an invalid FP exception if either argument is any NaN).
The condition code is implemented as a metadata string. The same set
of predicates as for the fcmp instruction is supported (except for the
"true" and "false" predicates).
These new intrinsics are mapped by SelectionDAG codegen onto two new
ISD opcodes, ISD::STRICT_FSETCC and ISD::STRICT_FSETCCS, again
representing quiet vs. signaling comparison operations. Otherwise
those nodes look like SETCC nodes, with an additional chain argument
and result as usual for strict FP nodes. The patch includes support
for the common legalization operations for those nodes.
The patch also includes full SystemZ back-end support for the new
ISD nodes, mapping them to all available SystemZ instruction to
fully implement strict semantics (scalar and vector).
Differential Revision: https://reviews.llvm.org/D69281
2019-12-06 18:30:04 +08:00
|
|
|
def KEB : CompareRXE<"keb", 0xED08, z_strict_fcmps, FP32, load, 4>;
|
|
|
|
def KDB : CompareRXE<"kdb", 0xED18, z_strict_fcmps, FP64, load, 8>;
|
2013-05-07 00:15:19 +08:00
|
|
|
}
|
|
|
|
|
2016-06-29 15:29:07 +08:00
|
|
|
// Test Data Class.
|
|
|
|
let Defs = [CC], CCValues = 0xC in {
|
|
|
|
def TCEB : TestRXE<"tceb", 0xED10, z_tdc, FP32>;
|
|
|
|
def TCDB : TestRXE<"tcdb", 0xED11, z_tdc, FP64>;
|
|
|
|
def TCXB : TestRXE<"tcxb", 0xED12, z_tdc, FP128>;
|
|
|
|
}
|
|
|
|
|
2016-12-03 02:21:53 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Floating-point control register instructions
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
let hasSideEffects = 1 in {
|
2017-12-05 19:24:39 +08:00
|
|
|
let mayLoad = 1, mayStore = 1 in {
|
|
|
|
// TODO: EFPC and SFPC do not touch memory at all
|
2019-05-13 17:47:26 +08:00
|
|
|
let Uses = [FPC] in {
|
|
|
|
def EFPC : InherentRRE<"efpc", 0xB38C, GR32, int_s390_efpc>;
|
|
|
|
def STFPC : StoreInherentS<"stfpc", 0xB29C, storei<int_s390_efpc>, 4>;
|
|
|
|
}
|
|
|
|
|
|
|
|
let Defs = [FPC] in {
|
|
|
|
def SFPC : SideEffectUnaryRRE<"sfpc", 0xB384, GR32, int_s390_sfpc>;
|
|
|
|
def LFPC : SideEffectUnaryS<"lfpc", 0xB29D, loadu<int_s390_sfpc>, 4>;
|
|
|
|
}
|
2017-12-05 19:24:39 +08:00
|
|
|
}
|
2016-12-03 02:21:53 +08:00
|
|
|
|
2019-06-06 06:33:10 +08:00
|
|
|
let Defs = [FPC], mayRaiseFPException = 1 in {
|
2019-05-13 17:47:26 +08:00
|
|
|
def SFASR : SideEffectUnaryRRE<"sfasr", 0xB385, GR32, null_frag>;
|
|
|
|
def LFAS : SideEffectUnaryS<"lfas", 0xB2BD, null_frag, 4>;
|
|
|
|
}
|
2016-12-03 02:21:53 +08:00
|
|
|
|
2019-05-13 17:47:26 +08:00
|
|
|
let Uses = [FPC], Defs = [FPC] in {
|
|
|
|
def SRNMB : SideEffectAddressS<"srnmb", 0xB2B8, null_frag, shift12only>,
|
|
|
|
Requires<[FeatureFPExtension]>;
|
|
|
|
def SRNM : SideEffectAddressS<"srnm", 0xB299, null_frag, shift12only>;
|
|
|
|
def SRNMT : SideEffectAddressS<"srnmt", 0xB2B9, null_frag, shift12only>;
|
|
|
|
}
|
2016-12-03 02:21:53 +08:00
|
|
|
}
|
|
|
|
|
2013-05-07 00:15:19 +08:00
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
// Peepholes
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2015-10-02 02:12:28 +08:00
|
|
|
def : Pat<(f32 fpimmneg0), (LCDFR_32 (LZER))>;
|
|
|
|
def : Pat<(f64 fpimmneg0), (LCDFR (LZDR))>;
|
2013-05-07 00:15:19 +08:00
|
|
|
def : Pat<(f128 fpimmneg0), (LCXBR (LZXR))>;
|