mirror of
https://github.com/RPCS3/llvm.git
synced 2024-11-30 23:21:04 +00:00
GlobalISel: Add buildFConstant for APFloat
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@360853 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
786b357990
commit
974b6989da
@ -632,6 +632,7 @@ public:
|
||||
const ConstantFP &Val);
|
||||
|
||||
MachineInstrBuilder buildFConstant(const DstOp &Res, double Val);
|
||||
MachineInstrBuilder buildFConstant(const DstOp &Res, const APFloat &Val);
|
||||
|
||||
/// Build and insert \p Res = COPY Op
|
||||
///
|
||||
|
@ -312,6 +312,13 @@ MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
|
||||
return buildFConstant(Res, *CFP);
|
||||
}
|
||||
|
||||
MachineInstrBuilder MachineIRBuilder::buildFConstant(const DstOp &Res,
|
||||
const APFloat &Val) {
|
||||
auto &Ctx = getMF().getFunction().getContext();
|
||||
auto *CFP = ConstantFP::get(Ctx, Val);
|
||||
return buildFConstant(Res, *CFP);
|
||||
}
|
||||
|
||||
MachineInstrBuilder MachineIRBuilder::buildBrCond(unsigned Tst,
|
||||
MachineBasicBlock &Dest) {
|
||||
assert(getMRI()->getType(Tst).isScalar() && "invalid operand type");
|
||||
|
@ -19,6 +19,10 @@ TEST_F(GISelMITest, TestBuildConstantFConstant) {
|
||||
B.buildConstant(LLT::vector(2, 32), 99);
|
||||
B.buildFConstant(LLT::vector(2, 32), 2.0);
|
||||
|
||||
// Test APFloat overload.
|
||||
APFloat KVal(APFloat::IEEEdouble(), "4.0");
|
||||
B.buildFConstant(LLT::scalar(64), KVal);
|
||||
|
||||
auto CheckStr = R"(
|
||||
CHECK: [[CONST0:%[0-9]+]]:_(s32) = G_CONSTANT i32 42
|
||||
CHECK: [[FCONST0:%[0-9]+]]:_(s32) = G_FCONSTANT float 1.000000e+00
|
||||
@ -26,6 +30,7 @@ TEST_F(GISelMITest, TestBuildConstantFConstant) {
|
||||
CHECK: [[VEC0:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[CONST1]]:_(s32), [[CONST1]]:_(s32)
|
||||
CHECK: [[FCONST1:%[0-9]+]]:_(s32) = G_FCONSTANT float 2.000000e+00
|
||||
CHECK: [[VEC1:%[0-9]+]]:_(<2 x s32>) = G_BUILD_VECTOR [[FCONST1]]:_(s32), [[FCONST1]]:_(s32)
|
||||
CHECK: [[FCONST2:%[0-9]+]]:_(s64) = G_FCONSTANT double 4.000000e+00
|
||||
)";
|
||||
|
||||
EXPECT_TRUE(CheckMachineFunction(*MF, CheckStr)) << *MF;
|
||||
|
Loading…
Reference in New Issue
Block a user