@@ -1499,6 +1499,7 @@ define void @foo(i32 %arg, float %farg, double %darg, ptr %ptr) {
14991499 EXPECT_EQ (SExt->getDestTy (), Ti64);
15001500
15011501 auto *FPToUI = cast<sandboxir::CastInst>(&*It++);
1502+ EXPECT_TRUE (isa<sandboxir::FPToUIInst>(FPToUI));
15021503 EXPECT_EQ (FPToUI->getOpcode (), sandboxir::Instruction::Opcode::FPToUI);
15031504 EXPECT_EQ (FPToUI->getSrcTy (), Tfloat);
15041505 EXPECT_EQ (FPToUI->getDestTy (), Ti32);
@@ -1618,6 +1619,75 @@ define void @foo(i32 %arg, float %farg, double %darg, ptr %ptr) {
16181619 }
16191620}
16201621
1622+ TEST_F (SandboxIRTest, FPToUIInst) {
1623+ parseIR (C, R"IR(
1624+ define void @foo(float %arg) {
1625+ %fptoui = fptoui float %arg to i32
1626+ ret void
1627+ }
1628+ )IR" );
1629+ Function &LLVMF = *M->getFunction (" foo" );
1630+ sandboxir::Context Ctx (C);
1631+ sandboxir::Function *F = Ctx.createFunction (&LLVMF);
1632+ unsigned ArgIdx = 0 ;
1633+ auto *Arg = F->getArg (ArgIdx++);
1634+ auto *BB = &*F->begin ();
1635+ auto It = BB->begin ();
1636+ Type *Ti32 = Type::getInt32Ty (C);
1637+ Type *Tfloat = Type::getFloatTy (C);
1638+
1639+ auto *FPToUI = cast<sandboxir::FPToUIInst>(&*It++);
1640+ EXPECT_EQ (FPToUI->getOpcode (), sandboxir::Instruction::Opcode::FPToUI);
1641+ EXPECT_EQ (FPToUI->getSrcTy (), Tfloat);
1642+ EXPECT_EQ (FPToUI->getDestTy (), Ti32);
1643+ auto *Ret = cast<sandboxir::ReturnInst>(&*It++);
1644+
1645+ {
1646+ // Check create() WhereIt, WhereBB
1647+ auto *NewI = cast<sandboxir::FPToUIInst>(
1648+ sandboxir::FPToUIInst::create (Arg, Ti32, /* WhereIt=*/ BB->end (),
1649+ /* WhereBB=*/ BB, Ctx, " FPToUI" ));
1650+ // Check getOpcode().
1651+ EXPECT_EQ (NewI->getOpcode (), sandboxir::Instruction::Opcode::FPToUI);
1652+ // Check getSrcTy().
1653+ EXPECT_EQ (NewI->getSrcTy (), Arg->getType ());
1654+ // Check getDestTy().
1655+ EXPECT_EQ (NewI->getDestTy (), Ti32);
1656+ // Check instr position.
1657+ EXPECT_EQ (NewI->getNextNode (), nullptr );
1658+ EXPECT_EQ (NewI->getPrevNode (), Ret);
1659+ }
1660+ {
1661+ // Check create() InsertBefore.
1662+ auto *NewI = cast<sandboxir::FPToUIInst>(
1663+ sandboxir::FPToUIInst::create (Arg, Ti32,
1664+ /* InsertBefore=*/ Ret, Ctx, " FPToUI" ));
1665+ // Check getOpcode().
1666+ EXPECT_EQ (NewI->getOpcode (), sandboxir::Instruction::Opcode::FPToUI);
1667+ // Check getSrcTy().
1668+ EXPECT_EQ (NewI->getSrcTy (), Arg->getType ());
1669+ // Check getDestTy().
1670+ EXPECT_EQ (NewI->getDestTy (), Ti32);
1671+ // Check instr position.
1672+ EXPECT_EQ (NewI->getNextNode (), Ret);
1673+ }
1674+ {
1675+ // Check create() InsertAtEnd.
1676+ auto *NewI = cast<sandboxir::FPToUIInst>(
1677+ sandboxir::FPToUIInst::create (Arg, Ti32,
1678+ /* InsertAtEnd=*/ BB, Ctx, " FPToUI" ));
1679+ // Check getOpcode().
1680+ EXPECT_EQ (NewI->getOpcode (), sandboxir::Instruction::Opcode::FPToUI);
1681+ // Check getSrcTy().
1682+ EXPECT_EQ (NewI->getSrcTy (), Arg->getType ());
1683+ // Check getDestTy().
1684+ EXPECT_EQ (NewI->getDestTy (), Ti32);
1685+ // Check instr position.
1686+ EXPECT_EQ (NewI->getNextNode (), nullptr );
1687+ EXPECT_EQ (NewI->getParent (), BB);
1688+ }
1689+ }
1690+
16211691TEST_F (SandboxIRTest, FPToSIInst) {
16221692 parseIR (C, R"IR(
16231693define void @foo(float %arg) {
0 commit comments