Lines Matching full:layout

24 constexpr static llvm::StringLiteral kAttrName = "dltest.layout";
38 /// Trivial array storage for the custom data layout spec attribute, just a list
58 /// Simple data layout spec containing a list of entries that always verifies
151 /// A type subject to data layout that exits the program if it is queried more
164 llvm::TypeSize getTypeSizeInBits(const DataLayout &layout,
174 uint64_t getABIAlignment(const DataLayout &layout,
184 uint64_t getPreferredAlignment(const DataLayout &layout,
231 /// A types that is not subject to data layout.
242 /// An op that serves as scope for data layout queries with the relevant
243 /// attribute attached. This can handle data layout requests for the built-in
462 DataLayout layout(module.get());
463 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 6u);
464 EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 2u);
465 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 42)), 42u);
466 EXPECT_EQ(layout.getTypeSizeInBits(Float16Type::get(&ctx)), 16u);
467 EXPECT_EQ(layout.getTypeABIAlignment(IntegerType::get(&ctx, 42)), 8u);
468 EXPECT_EQ(layout.getTypeABIAlignment(Float16Type::get(&ctx)), 2u);
469 EXPECT_EQ(layout.getTypePreferredAlignment(IntegerType::get(&ctx, 42)), 8u);
470 EXPECT_EQ(layout.getTypePreferredAlignment(Float16Type::get(&ctx)), 2u);
472 EXPECT_EQ(layout.getEndianness(), Attribute());
473 EXPECT_EQ(layout.getAllocaMemorySpace(), Attribute());
474 EXPECT_EQ(layout.getProgramMemorySpace(), Attribute());
475 EXPECT_EQ(layout.getGlobalMemorySpace(), Attribute());
476 EXPECT_EQ(layout.getStackAlignment(), 0u);
491 DataLayout layout(op);
493 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 42u);
494 EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 16u);
495 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 42)), 8u * 42u);
496 EXPECT_EQ(layout.getTypeSizeInBits(Float16Type::get(&ctx)), 8u * 16u);
497 EXPECT_EQ(layout.getTypeABIAlignment(IntegerType::get(&ctx, 42)), 64u);
498 EXPECT_EQ(layout.getTypeABIAlignment(Float16Type::get(&ctx)), 16u);
499 EXPECT_EQ(layout.getTypePreferredAlignment(IntegerType::get(&ctx, 42)), 128u);
500 EXPECT_EQ(layout.getTypePreferredAlignment(Float16Type::get(&ctx)), 32u);
501 EXPECT_EQ(layout.getTypeIndexBitwidth(Float16Type::get(&ctx)), std::nullopt);
502 EXPECT_EQ(layout.getTypeIndexBitwidth(IndexType::get(&ctx)), 64u);
504 EXPECT_EQ(layout.getEndianness(), Attribute());
505 EXPECT_EQ(layout.getAllocaMemorySpace(), Attribute());
506 EXPECT_EQ(layout.getProgramMemorySpace(), Attribute());
507 EXPECT_EQ(layout.getGlobalMemorySpace(), Attribute());
508 EXPECT_EQ(layout.getStackAlignment(), 0u);
510 EXPECT_EQ(layout.getDevicePropertyValue(
514 EXPECT_EQ(layout.getDevicePropertyValue(
522 "dltest.op_with_layout"() { dltest.layout = #dltest.spec< > } : () -> ()
532 DataLayout layout(op);
533 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 42u);
534 EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 16u);
535 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 42)), 8u * 42u);
536 EXPECT_EQ(layout.getTypeSizeInBits(Float16Type::get(&ctx)), 8u * 16u);
537 EXPECT_EQ(layout.getTypeABIAlignment(IntegerType::get(&ctx, 42)), 64u);
538 EXPECT_EQ(layout.getTypeABIAlignment(Float16Type::get(&ctx)), 16u);
539 EXPECT_EQ(layout.getTypePreferredAlignment(IntegerType::get(&ctx, 42)), 128u);
540 EXPECT_EQ(layout.getTypePreferredAlignment(Float16Type::get(&ctx)), 32u);
541 EXPECT_EQ(layout.getTypeIndexBitwidth(Float16Type::get(&ctx)), std::nullopt);
542 EXPECT_EQ(layout.getTypeIndexBitwidth(IndexType::get(&ctx)), 64u);
544 EXPECT_EQ(layout.getEndianness(), Attribute());
545 EXPECT_EQ(layout.getAllocaMemorySpace(), Attribute());
546 EXPECT_EQ(layout.getProgramMemorySpace(), Attribute());
547 EXPECT_EQ(layout.getGlobalMemorySpace(), Attribute());
548 EXPECT_EQ(layout.getStackAlignment(), 0u);
550 EXPECT_EQ(layout.getDevicePropertyValue(
554 EXPECT_EQ(layout.getDevicePropertyValue(
562 "dltest.op_with_layout"() { dltest.layout = #dltest.spec<
581 DataLayout layout(op);
582 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 5u);
583 EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 6u);
584 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 42)), 40u);
585 EXPECT_EQ(layout.getTypeSizeInBits(Float16Type::get(&ctx)), 48u);
586 EXPECT_EQ(layout.getTypeABIAlignment(IntegerType::get(&ctx, 42)), 8u);
587 EXPECT_EQ(layout.getTypeABIAlignment(Float16Type::get(&ctx)), 8u);
588 EXPECT_EQ(layout.getTypePreferredAlignment(IntegerType::get(&ctx, 42)), 16u);
589 EXPECT_EQ(layout.getTypePreferredAlignment(Float16Type::get(&ctx)), 16u);
590 EXPECT_EQ(layout.getTypeIndexBitwidth(Float16Type::get(&ctx)), std::nullopt);
591 EXPECT_EQ(layout.getTypeIndexBitwidth(IndexType::get(&ctx)), 42u);
593 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 32)), 32u);
594 EXPECT_EQ(layout.getTypeSize(Float32Type::get(&ctx)), 32u);
595 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 32)), 256u);
596 EXPECT_EQ(layout.getTypeSizeInBits(Float32Type::get(&ctx)), 256u);
597 EXPECT_EQ(layout.getTypeABIAlignment(IntegerType::get(&ctx, 32)), 32u);
598 EXPECT_EQ(layout.getTypeABIAlignment(Float32Type::get(&ctx)), 32u);
599 EXPECT_EQ(layout.getTypePreferredAlignment(IntegerType::get(&ctx, 32)), 64u);
600 EXPECT_EQ(layout.getTypePreferredAlignment(Float32Type::get(&ctx)), 64u);
602 EXPECT_EQ(layout.getEndianness(), Builder(&ctx).getStringAttr("little"));
603 EXPECT_EQ(layout.getAllocaMemorySpace(), Builder(&ctx).getI32IntegerAttr(5));
604 EXPECT_EQ(layout.getProgramMemorySpace(), Builder(&ctx).getI32IntegerAttr(3));
605 EXPECT_EQ(layout.getGlobalMemorySpace(), Builder(&ctx).getI32IntegerAttr(2));
606 EXPECT_EQ(layout.getStackAlignment(), 128u);
624 DataLayout layout(*module);
625 EXPECT_EQ(layout.getDevicePropertyValue(
629 EXPECT_EQ(layout.getDevicePropertyValue(
637 "dltest.op_with_layout"() { dltest.layout = #dltest.spec<> } : () -> ()
647 DataLayout layout(op);
650 sum += layout.getTypeSize(SingleQueryType::get(&ctx));
653 sum += layout.getTypeSize(SingleQueryType::get(&ctx));
657 // A fresh data layout has a new cache, so the call to it should be dispatched
665 "dltest.op_with_layout"() { dltest.layout = #dltest.spec<
678 DataLayout layout(op);
681 EXPECT_EQ(layout.getTypeSize(Float16Type::get(&ctx)), 6u);
683 // Replace the data layout spec with a new, empty spec.
686 // Data layout is no longer valid and should trigger assertion when queried.
688 ASSERT_DEATH(layout.getTypeSize(Float16Type::get(&ctx)), "no longer valid");
694 "dltest.op_with_layout"() { dltest.layout = #dltest.spec<> } : () -> ()
704 DataLayout layout(op);
706 ASSERT_DEATH(layout.getTypeSize(TypeNoLayout::get(&ctx)),
707 "neither the scoping op nor the type class provide data layout "
713 "dltest.op_with_7bit_byte"() { dltest.layout = #dltest.spec<> } : () -> ()
723 DataLayout layout(op);
725 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 42)), 42u);
726 EXPECT_EQ(layout.getTypeSizeInBits(IntegerType::get(&ctx, 32)), 32u);
727 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 42)), 6u);
728 EXPECT_EQ(layout.getTypeSize(IntegerType::get(&ctx, 32)), 5u);