1 //===- TypesTest.cpp ------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
9 #include "llvm/ADT/SmallPtrSet.h"
10 #include "llvm/AsmParser/Parser.h"
11 #include "llvm/IR/BasicBlock.h"
12 #include "llvm/IR/Constants.h"
13 #include "llvm/IR/DataLayout.h"
14 #include "llvm/IR/Function.h"
15 #include "llvm/IR/Instruction.h"
16 #include "llvm/IR/Module.h"
17 #include "llvm/SandboxIR/Constant.h"
18 #include "llvm/SandboxIR/Context.h"
19 #include "llvm/SandboxIR/Function.h"
20 #include "llvm/Support/SourceMgr.h"
21 #include "gtest/gtest.h"
25 struct SandboxTypeTest
: public testing::Test
{
27 std::unique_ptr
<Module
> M
;
29 void parseIR(LLVMContext
&C
, const char *IR
) {
31 M
= parseAssemblyString(IR
, Err
, C
);
33 Err
.print("SandboxTypeTest", errs());
35 BasicBlock
*getBasicBlockByName(Function
&F
, StringRef Name
) {
36 for (BasicBlock
&BB
: F
)
37 if (BB
.getName() == Name
)
39 llvm_unreachable("Expected to find basic block!");
43 TEST_F(SandboxTypeTest
, Type
) {
45 define void @foo(i32 %v0) {
49 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
50 sandboxir::Context
Ctx(C
);
51 auto *F
= Ctx
.createFunction(LLVMF
);
52 sandboxir::Type
*I32Ty
= F
->getArg(0)->getType();
54 auto *LLVMInt32Ty
= llvm::Type::getInt32Ty(C
);
55 auto *LLVMFloatTy
= llvm::Type::getFloatTy(C
);
56 auto *LLVMInt8Ty
= llvm::Type::getInt8Ty(C
);
58 auto *Int32Ty
= Ctx
.getType(LLVMInt32Ty
);
59 auto *FloatTy
= Ctx
.getType(LLVMFloatTy
);
63 raw_string_ostream
BS1(Buff1
);
64 Int32Ty
->print(BS1
, /*IsForDebug=*/true, /*NoDetails=*/false);
66 raw_string_ostream
BS2(Buff2
);
67 LLVMInt32Ty
->print(BS2
, /*IsForDebug=*/true, /*NoDetails=*/false);
68 EXPECT_EQ(Buff1
, Buff2
);
70 // Check getContext().
71 EXPECT_EQ(&I32Ty
->getContext(), &Ctx
);
72 // Check that Ctx.getType(nullptr) == nullptr.
73 EXPECT_EQ(Ctx
.getType(nullptr), nullptr);
75 #define CHK(LLVMCreate, SBCheck) \
76 Ctx.getType(llvm::Type::LLVMCreate(C))->SBCheck()
78 EXPECT_TRUE(Ctx
.getType(llvm::Type::getVoidTy(C
))->isVoidTy());
79 EXPECT_TRUE(CHK(getVoidTy
, isVoidTy
));
81 EXPECT_TRUE(CHK(getHalfTy
, isHalfTy
));
82 // Check isBFloatTy().
83 EXPECT_TRUE(CHK(getBFloatTy
, isBFloatTy
));
84 // Check is16bitFPTy().
85 EXPECT_TRUE(CHK(getHalfTy
, is16bitFPTy
));
87 EXPECT_TRUE(CHK(getFloatTy
, isFloatTy
));
88 // Check isDoubleTy().
89 EXPECT_TRUE(CHK(getDoubleTy
, isDoubleTy
));
90 // Check isX86_FP80Ty().
91 EXPECT_TRUE(CHK(getX86_FP80Ty
, isX86_FP80Ty
));
93 EXPECT_TRUE(CHK(getFP128Ty
, isFP128Ty
));
94 // Check isPPC_FP128Ty().
95 EXPECT_TRUE(CHK(getPPC_FP128Ty
, isPPC_FP128Ty
));
96 // Check isIEEELikeFPTy().
97 EXPECT_TRUE(CHK(getFloatTy
, isIEEELikeFPTy
));
98 // Check isFloatingPointTy().
99 EXPECT_TRUE(CHK(getFloatTy
, isFloatingPointTy
));
100 EXPECT_TRUE(CHK(getDoubleTy
, isFloatingPointTy
));
101 // Check isMultiUnitFPType().
102 EXPECT_TRUE(CHK(getPPC_FP128Ty
, isMultiUnitFPType
));
103 EXPECT_FALSE(CHK(getFloatTy
, isMultiUnitFPType
));
104 // Check getFltSemantics().
105 EXPECT_EQ(&sandboxir::Type::getFloatTy(Ctx
)->getFltSemantics(),
106 &llvm::Type::getFloatTy(C
)->getFltSemantics());
107 // Check isX86_AMXTy().
108 EXPECT_TRUE(CHK(getX86_AMXTy
, isX86_AMXTy
));
109 // Check isTargetExtTy().
110 EXPECT_TRUE(Ctx
.getType(llvm::TargetExtType::get(C
, "foo"))->isTargetExtTy());
111 // Check isScalableTargetExtTy().
112 EXPECT_TRUE(Ctx
.getType(llvm::TargetExtType::get(C
, "aarch64.svcount"))
113 ->isScalableTargetExtTy());
114 // Check isScalableTy().
115 EXPECT_TRUE(Ctx
.getType(llvm::ScalableVectorType::get(LLVMInt32Ty
, 2u))
117 // Check isFPOrFPVectorTy().
118 EXPECT_TRUE(CHK(getFloatTy
, isFPOrFPVectorTy
));
119 EXPECT_FALSE(CHK(getInt32Ty
, isFPOrFPVectorTy
));
120 // Check isLabelTy().
121 EXPECT_TRUE(CHK(getLabelTy
, isLabelTy
));
122 // Check isMetadataTy().
123 EXPECT_TRUE(CHK(getMetadataTy
, isMetadataTy
));
124 // Check isTokenTy().
125 EXPECT_TRUE(CHK(getTokenTy
, isTokenTy
));
126 // Check isIntegerTy().
127 EXPECT_TRUE(CHK(getInt32Ty
, isIntegerTy
));
128 EXPECT_FALSE(CHK(getFloatTy
, isIntegerTy
));
129 // Check isIntegerTy(Bitwidth).
130 EXPECT_TRUE(LLVMInt32Ty
->isIntegerTy(32u));
131 EXPECT_FALSE(LLVMInt32Ty
->isIntegerTy(31u));
132 EXPECT_FALSE(Ctx
.getType(llvm::Type::getFloatTy(C
))->isIntegerTy(32u));
133 // Check isIntOrIntVectorTy().
134 EXPECT_TRUE(LLVMInt32Ty
->isIntOrIntVectorTy());
135 EXPECT_TRUE(Ctx
.getType(llvm::FixedVectorType::get(LLVMInt32Ty
, 8))
136 ->isIntOrIntVectorTy());
137 EXPECT_FALSE(Ctx
.getType(LLVMFloatTy
)->isIntOrIntVectorTy());
138 EXPECT_FALSE(Ctx
.getType(llvm::FixedVectorType::get(LLVMFloatTy
, 8))
139 ->isIntOrIntVectorTy());
140 // Check isIntOrPtrTy().
141 EXPECT_TRUE(Int32Ty
->isIntOrPtrTy());
142 EXPECT_TRUE(Ctx
.getType(llvm::PointerType::get(C
, 0u))->isIntOrPtrTy());
143 EXPECT_FALSE(FloatTy
->isIntOrPtrTy());
144 // Check isFunctionTy().
145 EXPECT_TRUE(Ctx
.getType(llvm::FunctionType::get(LLVMInt32Ty
, {}, false))
147 // Check isStructTy().
148 EXPECT_TRUE(Ctx
.getType(llvm::StructType::get(C
))->isStructTy());
149 // Check isArrayTy().
150 EXPECT_TRUE(Ctx
.getType(llvm::ArrayType::get(LLVMInt32Ty
, 10))->isArrayTy());
151 // Check isPointerTy().
152 EXPECT_TRUE(Ctx
.getType(llvm::PointerType::get(C
, 0u))->isPointerTy());
153 // Check isPtrOrPtrVectroTy().
155 Ctx
.getType(llvm::FixedVectorType::get(llvm::PointerType::get(C
, 0u), 8u))
156 ->isPtrOrPtrVectorTy());
157 // Check isVectorTy().
159 Ctx
.getType(llvm::FixedVectorType::get(LLVMInt32Ty
, 8u))->isVectorTy());
160 // Check canLosslesslyBitCastTo().
161 auto *VecTy32x4
= Ctx
.getType(llvm::FixedVectorType::get(LLVMInt32Ty
, 4u));
162 auto *VecTy32x2
= Ctx
.getType(llvm::FixedVectorType::get(LLVMInt32Ty
, 2u));
163 auto *VecTy8x16
= Ctx
.getType(llvm::FixedVectorType::get(LLVMInt8Ty
, 16u));
164 EXPECT_TRUE(VecTy32x4
->canLosslesslyBitCastTo(VecTy8x16
));
165 EXPECT_FALSE(VecTy32x4
->canLosslesslyBitCastTo(VecTy32x2
));
166 // Check isEmptyTy().
167 EXPECT_TRUE(Ctx
.getType(llvm::StructType::get(C
))->isEmptyTy());
168 // Check isFirstClassType().
169 EXPECT_TRUE(Int32Ty
->isFirstClassType());
170 // Check isSingleValueType().
171 EXPECT_TRUE(Int32Ty
->isSingleValueType());
172 // Check isAggregateType().
173 EXPECT_FALSE(Int32Ty
->isAggregateType());
175 SmallPtrSet
<sandboxir::Type
*, 1> Visited
;
176 EXPECT_TRUE(Int32Ty
->isSized(&Visited
));
177 // Check getPrimitiveSizeInBits().
178 EXPECT_EQ(VecTy32x2
->getPrimitiveSizeInBits(), 32u * 2);
179 // Check getScalarSizeInBits().
180 EXPECT_EQ(VecTy32x2
->getScalarSizeInBits(), 32u);
181 // Check getFPMantissaWidth().
182 EXPECT_EQ(FloatTy
->getFPMantissaWidth(), LLVMFloatTy
->getFPMantissaWidth());
184 EXPECT_EQ(FloatTy
->isIEEE(), LLVMFloatTy
->isIEEE());
185 // Check getScalarType().
187 Ctx
.getType(llvm::FixedVectorType::get(LLVMInt32Ty
, 8u))->getScalarType(),
190 #define CHK_GET(TY) \
191 EXPECT_EQ(Ctx.getType(llvm::Type::get##TY##Ty(C)), \
192 sandboxir::Type::get##TY##Ty(Ctx))
193 // Check getInt64Ty().
195 // Check getInt32Ty().
197 // Check getInt16Ty().
199 // Check getInt8Ty().
201 // Check getInt1Ty().
203 // Check getDoubleTy().
205 // Check getFloatTy().
209 TEST_F(SandboxTypeTest
, PointerType
) {
211 define void @foo(ptr %ptr) {
215 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
216 sandboxir::Context
Ctx(C
);
217 auto *F
= Ctx
.createFunction(LLVMF
);
218 // Check classof(), creation.
219 auto *PtrTy
= cast
<sandboxir::PointerType
>(F
->getArg(0)->getType());
220 // Check get(ElementType, AddressSpace).
222 sandboxir::PointerType::get(sandboxir::Type::getInt32Ty(Ctx
), 0u);
223 EXPECT_EQ(NewPtrTy
, PtrTy
);
224 // Check get(Ctx, AddressSpace).
225 auto *NewPtrTy2
= sandboxir::PointerType::get(Ctx
, 0u);
226 EXPECT_EQ(NewPtrTy2
, PtrTy
);
229 TEST_F(SandboxTypeTest
, ArrayType
) {
231 define void @foo([2 x i8] %v0) {
235 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
236 sandboxir::Context
Ctx(C
);
237 auto *F
= Ctx
.createFunction(LLVMF
);
238 // Check classof(), creation.
239 [[maybe_unused
]] auto *ArrayTy
=
240 cast
<sandboxir::ArrayType
>(F
->getArg(0)->getType());
243 sandboxir::ArrayType::get(sandboxir::Type::getInt8Ty(Ctx
), 2u);
244 EXPECT_EQ(NewArrayTy
, ArrayTy
);
247 TEST_F(SandboxTypeTest
, StructType
) {
249 define void @foo({i32, i8} %v0) {
253 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
254 sandboxir::Context
Ctx(C
);
255 auto *F
= Ctx
.createFunction(LLVMF
);
256 auto *Int32Ty
= sandboxir::Type::getInt32Ty(Ctx
);
257 auto *Int8Ty
= sandboxir::Type::getInt8Ty(Ctx
);
258 // Check classof(), creation.
259 [[maybe_unused
]] auto *StructTy
=
260 cast
<sandboxir::StructType
>(F
->getArg(0)->getType());
262 auto *NewStructTy
= sandboxir::StructType::get(Ctx
, {Int32Ty
, Int8Ty
});
263 EXPECT_EQ(NewStructTy
, StructTy
);
264 // Check get(Packed).
265 auto *NewStructTyPacked
=
266 sandboxir::StructType::get(Ctx
, {Int32Ty
, Int8Ty
}, /*Packed=*/true);
267 EXPECT_NE(NewStructTyPacked
, StructTy
);
268 EXPECT_TRUE(NewStructTyPacked
->isPacked());
271 TEST_F(SandboxTypeTest
, VectorType
) {
273 define void @foo(<4 x i16> %vi0, <4 x float> %vf1, i8 %i0) {
277 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
278 sandboxir::Context
Ctx(C
);
279 auto *F
= Ctx
.createFunction(LLVMF
);
280 // Check classof(), creation, accessors
281 auto *VecTy
= cast
<sandboxir::VectorType
>(F
->getArg(0)->getType());
282 EXPECT_TRUE(VecTy
->getElementType()->isIntegerTy(16));
283 EXPECT_EQ(VecTy
->getElementCount(), ElementCount::getFixed(4));
285 // get(ElementType, NumElements, Scalable)
286 EXPECT_EQ(sandboxir::VectorType::get(sandboxir::Type::getInt16Ty(Ctx
), 4,
288 F
->getArg(0)->getType());
289 // get(ElementType, Other)
290 EXPECT_EQ(sandboxir::VectorType::get(
291 sandboxir::Type::getInt16Ty(Ctx
),
292 cast
<sandboxir::VectorType
>(F
->getArg(0)->getType())),
293 F
->getArg(0)->getType());
294 auto *FVecTy
= cast
<sandboxir::VectorType
>(F
->getArg(1)->getType());
295 EXPECT_TRUE(FVecTy
->getElementType()->isFloatTy());
297 auto *IVecTy
= sandboxir::VectorType::getInteger(FVecTy
);
298 EXPECT_TRUE(IVecTy
->getElementType()->isIntegerTy(32));
299 EXPECT_EQ(IVecTy
->getElementCount(), FVecTy
->getElementCount());
300 // getExtendedElementCountVectorType
301 auto *ExtVecTy
= sandboxir::VectorType::getExtendedElementVectorType(IVecTy
);
302 EXPECT_TRUE(ExtVecTy
->getElementType()->isIntegerTy(64));
303 EXPECT_EQ(ExtVecTy
->getElementCount(), VecTy
->getElementCount());
304 // getTruncatedElementVectorType
306 sandboxir::VectorType::getTruncatedElementVectorType(IVecTy
);
307 EXPECT_TRUE(TruncVecTy
->getElementType()->isIntegerTy(16));
308 EXPECT_EQ(TruncVecTy
->getElementCount(), VecTy
->getElementCount());
309 // getSubdividedVectorType
310 auto *SubVecTy
= sandboxir::VectorType::getSubdividedVectorType(VecTy
, 1);
311 EXPECT_TRUE(SubVecTy
->getElementType()->isIntegerTy(8));
312 EXPECT_EQ(SubVecTy
->getElementCount(), ElementCount::getFixed(8));
313 // getHalfElementsVectorType
314 auto *HalfVecTy
= sandboxir::VectorType::getHalfElementsVectorType(VecTy
);
315 EXPECT_TRUE(HalfVecTy
->getElementType()->isIntegerTy(16));
316 EXPECT_EQ(HalfVecTy
->getElementCount(), ElementCount::getFixed(2));
317 // getDoubleElementsVectorType
318 auto *DoubleVecTy
= sandboxir::VectorType::getDoubleElementsVectorType(VecTy
);
319 EXPECT_TRUE(DoubleVecTy
->getElementType()->isIntegerTy(16));
320 EXPECT_EQ(DoubleVecTy
->getElementCount(), ElementCount::getFixed(8));
321 // isValidElementType
322 auto *I8Type
= F
->getArg(2)->getType();
323 EXPECT_TRUE(I8Type
->isIntegerTy());
324 EXPECT_TRUE(sandboxir::VectorType::isValidElementType(I8Type
));
325 EXPECT_FALSE(sandboxir::VectorType::isValidElementType(FVecTy
));
328 TEST_F(SandboxTypeTest
, FixedVectorType
) {
330 define void @foo(<4 x i16> %vi0, <4 x float> %vf1, i8 %i0) {
334 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
335 sandboxir::Context
Ctx(C
);
336 auto *F
= Ctx
.createFunction(LLVMF
);
337 // Check classof(), creation, accessors
338 auto *Vec4i16Ty
= cast
<sandboxir::FixedVectorType
>(F
->getArg(0)->getType());
339 EXPECT_TRUE(Vec4i16Ty
->getElementType()->isIntegerTy(16));
340 EXPECT_EQ(Vec4i16Ty
->getElementCount(), ElementCount::getFixed(4));
342 // get(ElementType, NumElements)
344 sandboxir::FixedVectorType::get(sandboxir::Type::getInt16Ty(Ctx
), 4),
345 F
->getArg(0)->getType());
346 // get(ElementType, Other)
347 EXPECT_EQ(sandboxir::FixedVectorType::get(
348 sandboxir::Type::getInt16Ty(Ctx
),
349 cast
<sandboxir::FixedVectorType
>(F
->getArg(0)->getType())),
350 F
->getArg(0)->getType());
351 auto *Vec4FTy
= cast
<sandboxir::FixedVectorType
>(F
->getArg(1)->getType());
352 EXPECT_TRUE(Vec4FTy
->getElementType()->isFloatTy());
354 auto *Vec4i32Ty
= sandboxir::FixedVectorType::getInteger(Vec4FTy
);
355 EXPECT_TRUE(Vec4i32Ty
->getElementType()->isIntegerTy(32));
356 EXPECT_EQ(Vec4i32Ty
->getElementCount(), Vec4FTy
->getElementCount());
357 // getExtendedElementCountVectorType
359 sandboxir::FixedVectorType::getExtendedElementVectorType(Vec4i16Ty
);
360 EXPECT_TRUE(Vec4i64Ty
->getElementType()->isIntegerTy(32));
361 EXPECT_EQ(Vec4i64Ty
->getElementCount(), Vec4i16Ty
->getElementCount());
362 // getTruncatedElementVectorType
364 sandboxir::FixedVectorType::getTruncatedElementVectorType(Vec4i16Ty
);
365 EXPECT_TRUE(Vec4i8Ty
->getElementType()->isIntegerTy(8));
366 EXPECT_EQ(Vec4i8Ty
->getElementCount(), Vec4i8Ty
->getElementCount());
367 // getSubdividedVectorType
369 sandboxir::FixedVectorType::getSubdividedVectorType(Vec4i16Ty
, 1);
370 EXPECT_TRUE(Vec8i8Ty
->getElementType()->isIntegerTy(8));
371 EXPECT_EQ(Vec8i8Ty
->getElementCount(), ElementCount::getFixed(8));
373 EXPECT_EQ(Vec8i8Ty
->getNumElements(), 8u);
374 // getHalfElementsVectorType
376 sandboxir::FixedVectorType::getHalfElementsVectorType(Vec4i16Ty
);
377 EXPECT_TRUE(Vec2i16Ty
->getElementType()->isIntegerTy(16));
378 EXPECT_EQ(Vec2i16Ty
->getElementCount(), ElementCount::getFixed(2));
379 // getDoubleElementsVectorType
381 sandboxir::FixedVectorType::getDoubleElementsVectorType(Vec4i16Ty
);
382 EXPECT_TRUE(Vec8i16Ty
->getElementType()->isIntegerTy(16));
383 EXPECT_EQ(Vec8i16Ty
->getElementCount(), ElementCount::getFixed(8));
386 TEST_F(SandboxTypeTest
, ScalableVectorType
) {
388 define void @foo(<vscale x 4 x i16> %vi0, <vscale x 4 x float> %vf1, i8 %i0) {
392 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
393 sandboxir::Context
Ctx(C
);
394 auto *F
= Ctx
.createFunction(LLVMF
);
395 // Check classof(), creation, accessors
397 cast
<sandboxir::ScalableVectorType
>(F
->getArg(0)->getType());
398 EXPECT_TRUE(Vec4i16Ty
->getElementType()->isIntegerTy(16));
399 EXPECT_EQ(Vec4i16Ty
->getMinNumElements(), 4u);
401 // get(ElementType, NumElements)
403 sandboxir::ScalableVectorType::get(sandboxir::Type::getInt16Ty(Ctx
), 4),
404 F
->getArg(0)->getType());
405 // get(ElementType, Other)
406 EXPECT_EQ(sandboxir::ScalableVectorType::get(
407 sandboxir::Type::getInt16Ty(Ctx
),
408 cast
<sandboxir::ScalableVectorType
>(F
->getArg(0)->getType())),
409 F
->getArg(0)->getType());
410 auto *Vec4FTy
= cast
<sandboxir::ScalableVectorType
>(F
->getArg(1)->getType());
411 EXPECT_TRUE(Vec4FTy
->getElementType()->isFloatTy());
413 auto *Vec4i32Ty
= sandboxir::ScalableVectorType::getInteger(Vec4FTy
);
414 EXPECT_TRUE(Vec4i32Ty
->getElementType()->isIntegerTy(32));
415 EXPECT_EQ(Vec4i32Ty
->getMinNumElements(), Vec4FTy
->getMinNumElements());
416 // getExtendedElementCountVectorType
418 sandboxir::ScalableVectorType::getExtendedElementVectorType(Vec4i16Ty
);
419 EXPECT_TRUE(Vec4i64Ty
->getElementType()->isIntegerTy(32));
420 EXPECT_EQ(Vec4i64Ty
->getMinNumElements(), Vec4i16Ty
->getMinNumElements());
421 // getTruncatedElementVectorType
423 sandboxir::ScalableVectorType::getTruncatedElementVectorType(Vec4i16Ty
);
424 EXPECT_TRUE(Vec4i8Ty
->getElementType()->isIntegerTy(8));
425 EXPECT_EQ(Vec4i8Ty
->getMinNumElements(), Vec4i8Ty
->getMinNumElements());
426 // getSubdividedVectorType
428 sandboxir::ScalableVectorType::getSubdividedVectorType(Vec4i16Ty
, 1);
429 EXPECT_TRUE(Vec8i8Ty
->getElementType()->isIntegerTy(8));
430 EXPECT_EQ(Vec8i8Ty
->getMinNumElements(), 8u);
432 EXPECT_EQ(Vec8i8Ty
->getMinNumElements(), 8u);
433 // getHalfElementsVectorType
435 sandboxir::ScalableVectorType::getHalfElementsVectorType(Vec4i16Ty
);
436 EXPECT_TRUE(Vec2i16Ty
->getElementType()->isIntegerTy(16));
437 EXPECT_EQ(Vec2i16Ty
->getMinNumElements(), 2u);
438 // getDoubleElementsVectorType
440 sandboxir::ScalableVectorType::getDoubleElementsVectorType(Vec4i16Ty
);
441 EXPECT_TRUE(Vec8i16Ty
->getElementType()->isIntegerTy(16));
442 EXPECT_EQ(Vec8i16Ty
->getMinNumElements(), 8u);
445 TEST_F(SandboxTypeTest
, FunctionType
) {
451 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
452 sandboxir::Context
Ctx(C
);
453 auto *F
= Ctx
.createFunction(LLVMF
);
454 // Check classof(), creation.
455 [[maybe_unused
]] auto *FTy
=
456 cast
<sandboxir::FunctionType
>(F
->getFunctionType());
459 TEST_F(SandboxTypeTest
, IntegerType
) {
461 define void @foo(i32 %v0) {
465 llvm::Function
*LLVMF
= &*M
->getFunction("foo");
466 sandboxir::Context
Ctx(C
);
467 auto *F
= Ctx
.createFunction(LLVMF
);
468 // Check classof(), creation.
469 auto *Int32Ty
= cast
<sandboxir::IntegerType
>(F
->getArg(0)->getType());
471 auto *NewInt32Ty
= sandboxir::IntegerType::get(Ctx
, 32u);
472 EXPECT_EQ(NewInt32Ty
, Int32Ty
);