@@ -1517,6 +1517,160 @@ llvm::Metadata* SubGroupSizeMetaData::getSIMD_sizeNode( const llvm::MDNode* pPar
1517
1517
return pParentNode->getOperand (0 + offset).get ();
1518
1518
}
1519
1519
1520
+
1521
+
1522
+ // /
1523
+ // Ctor - loads the WorkgroupWalkOrderMetaData from the given metadata node
1524
+ //
1525
+ WorkgroupWalkOrderMetaData::WorkgroupWalkOrderMetaData (const llvm::MDNode* pNode, bool hasId) :
1526
+ _Mybase(pNode, hasId),
1527
+ m_Dim0(getDim0Node(pNode)),
1528
+ m_Dim1(getDim1Node(pNode)),
1529
+ m_Dim2(getDim2Node(pNode)),
1530
+ m_pNode(pNode)
1531
+ {}
1532
+
1533
+ // /
1534
+ // Default Ctor - creates the empty, not named SubGroupSizeMetaData object
1535
+ //
1536
+ WorkgroupWalkOrderMetaData::WorkgroupWalkOrderMetaData () :
1537
+ m_pNode(NULL )
1538
+ {}
1539
+
1540
+ // /
1541
+ // Ctor - creates the empty, named SubGroupSizeMetaData object
1542
+ //
1543
+ WorkgroupWalkOrderMetaData::WorkgroupWalkOrderMetaData (const char * name) :
1544
+ _Mybase(name),
1545
+ m_pNode(NULL )
1546
+ {}
1547
+
1548
+ bool WorkgroupWalkOrderMetaData::hasValue () const
1549
+ {
1550
+ if (m_Dim0.hasValue ())
1551
+ {
1552
+ return true ;
1553
+ }
1554
+
1555
+ if (m_Dim1.hasValue ())
1556
+ {
1557
+ return true ;
1558
+ }
1559
+
1560
+ if (m_Dim2.hasValue ())
1561
+ {
1562
+ return true ;
1563
+ }
1564
+
1565
+ return NULL != m_pNode || dirty ();
1566
+ }
1567
+
1568
+ // /
1569
+ // Returns true if any of the SubGroupSizeMetaData`s members has changed
1570
+ bool WorkgroupWalkOrderMetaData::dirty () const
1571
+ {
1572
+ if (m_Dim0.dirty ())
1573
+ {
1574
+ return true ;
1575
+ }
1576
+
1577
+ if (m_Dim1.dirty ())
1578
+ {
1579
+ return true ;
1580
+ }
1581
+
1582
+ if (m_Dim2.dirty ())
1583
+ {
1584
+ return true ;
1585
+ }
1586
+ return false ;
1587
+ }
1588
+
1589
+ // /
1590
+ // Discards the changes done to the SubGroupSizeMetaData instance
1591
+ void WorkgroupWalkOrderMetaData::discardChanges ()
1592
+ {
1593
+ m_Dim0.discardChanges ();
1594
+ m_Dim1.discardChanges ();
1595
+ m_Dim2.discardChanges ();
1596
+ }
1597
+
1598
+ // /
1599
+ // Generates the new MDNode hierarchy for the given structure
1600
+ llvm::Metadata* WorkgroupWalkOrderMetaData::generateNode (llvm::LLVMContext& context) const
1601
+ {
1602
+ llvm::SmallVector<llvm::Metadata*, 5 > args;
1603
+
1604
+ llvm::Metadata* pIDNode = _Mybase::generateNode (context);
1605
+ if (NULL != pIDNode)
1606
+ {
1607
+ args.push_back (pIDNode);
1608
+ }
1609
+
1610
+ args.push_back (m_Dim0.generateNode (context));
1611
+ args.push_back (m_Dim1.generateNode (context));
1612
+ args.push_back (m_Dim2.generateNode (context));
1613
+
1614
+ return llvm::MDNode::get (context, args);
1615
+ }
1616
+
1617
+ // /
1618
+ // Saves the structure changes to the given MDNode
1619
+ void WorkgroupWalkOrderMetaData::save (llvm::LLVMContext& context, llvm::MDNode* pNode) const
1620
+ {
1621
+ assert (pNode && " The target node should be valid pointer" );
1622
+
1623
+ // we assume that underlying metadata node has not changed under our foot
1624
+ if (pNode == m_pNode && !dirty ())
1625
+ {
1626
+ return ;
1627
+ }
1628
+ #if 0
1629
+ // check that we could save the new information to the given node without regenerating it
1630
+ if (!compatibleWith(pNode))
1631
+ {
1632
+ pNode->replaceAllUsesWith(generateNode(context));
1633
+ return;
1634
+ }
1635
+ #endif
1636
+
1637
+ m_Dim0.save (context, llvm::cast<llvm::MDNode>(getDim0Node (pNode)));
1638
+ m_Dim1.save (context, llvm::cast<llvm::MDNode>(getDim1Node (pNode)));
1639
+ m_Dim2.save (context, llvm::cast<llvm::MDNode>(getDim2Node (pNode)));
1640
+ }
1641
+
1642
+ llvm::Metadata* WorkgroupWalkOrderMetaData::getDim0Node (const llvm::MDNode* pParentNode) const
1643
+ {
1644
+ if (!pParentNode)
1645
+ {
1646
+ return NULL ;
1647
+ }
1648
+
1649
+ unsigned int offset = _Mybase::getStartIndex ();
1650
+ return pParentNode->getOperand (0 + offset).get ();
1651
+ }
1652
+
1653
+ llvm::Metadata* WorkgroupWalkOrderMetaData::getDim1Node (const llvm::MDNode* pParentNode) const
1654
+ {
1655
+ if (!pParentNode)
1656
+ {
1657
+ return NULL ;
1658
+ }
1659
+
1660
+ unsigned int offset = _Mybase::getStartIndex ();
1661
+ return pParentNode->getOperand (1 + offset).get ();
1662
+ }
1663
+
1664
+ llvm::Metadata* WorkgroupWalkOrderMetaData::getDim2Node (const llvm::MDNode* pParentNode) const
1665
+ {
1666
+ if (!pParentNode)
1667
+ {
1668
+ return NULL ;
1669
+ }
1670
+
1671
+ unsigned int offset = _Mybase::getStartIndex ();
1672
+ return pParentNode->getOperand (2 + offset).get ();
1673
+ }
1520
1674
1521
1675
1522
1676
// /
@@ -2242,6 +2396,7 @@ FunctionInfoMetaData::FunctionInfoMetaData(const llvm::MDNode* pNode, bool hasId
2242
2396
m_ThreadGroupSize(ThreadGroupSizeMetaData::get(getThreadGroupSizeNode(pNode), true)),
2243
2397
m_ThreadGroupSizeHint(ThreadGroupSizeMetaData::get(getThreadGroupSizeHintNode(pNode), true)),
2244
2398
m_SubGroupSize(SubGroupSizeMetaData::get(getSubGroupSizeNode(pNode), true)),
2399
+ m_WorkgroupWalkOrder(WorkgroupWalkOrderMetaData::get(getWorkgroupWalkOrderNode(pNode), true)),
2245
2400
m_LocalIDPresent(getLocalIDPresentNode(pNode)),
2246
2401
m_GroupIDPresent(getGroupIDPresentNode(pNode)),
2247
2402
m_GlobalOffsetPresent(getGlobalOffsetPresentNode(pNode)),
@@ -2270,6 +2425,7 @@ FunctionInfoMetaData::FunctionInfoMetaData(): m_Type("function_type"),
2270
2425
m_ThreadGroupSize(ThreadGroupSizeMetaDataHandle::ObjectType::get(" thread_group_size" )),
2271
2426
m_ThreadGroupSizeHint(ThreadGroupSizeMetaDataHandle::ObjectType::get(" thread_group_size_hint" )),
2272
2427
m_SubGroupSize(SubGroupSizeMetaDataHandle::ObjectType::get(" sub_group_size" )),
2428
+ m_WorkgroupWalkOrder(WorkgroupWalkOrderMetaDataHandle::ObjectType::get(" intel_reqd_workgroup_walk_order" )),
2273
2429
m_LocalIDPresent(" local_id_present" ),
2274
2430
m_GroupIDPresent(" group_id_present" ),
2275
2431
m_GlobalOffsetPresent(" global_offset_present" ),
@@ -2300,6 +2456,7 @@ FunctionInfoMetaData::FunctionInfoMetaData(const char* name):
2300
2456
m_ThreadGroupSize(ThreadGroupSizeMetaDataHandle::ObjectType::get(" thread_group_size" )),
2301
2457
m_ThreadGroupSizeHint(ThreadGroupSizeMetaDataHandle::ObjectType::get(" thread_group_size_hint" )),
2302
2458
m_SubGroupSize(SubGroupSizeMetaDataHandle::ObjectType::get(" sub_group_size" )),
2459
+ m_WorkgroupWalkOrder(WorkgroupWalkOrderMetaDataHandle::ObjectType::get(" intel_reqd_workgroup_walk_order" )),
2303
2460
m_LocalIDPresent(" local_id_present" ),
2304
2461
m_GroupIDPresent(" group_id_present" ),
2305
2462
m_GlobalOffsetPresent(" global_offset_present" ),
@@ -2356,6 +2513,12 @@ bool FunctionInfoMetaData::hasValue() const
2356
2513
{
2357
2514
return true ;
2358
2515
}
2516
+
2517
+
2518
+ if (m_WorkgroupWalkOrder->hasValue ())
2519
+ {
2520
+ return true ;
2521
+ }
2359
2522
2360
2523
2361
2524
if (m_LocalIDPresent.hasValue ())
@@ -2482,7 +2645,11 @@ bool FunctionInfoMetaData::dirty() const
2482
2645
if ( m_SubGroupSize.dirty () )
2483
2646
{
2484
2647
return true ;
2485
- }
2648
+ }
2649
+ if (m_WorkgroupWalkOrder.dirty ())
2650
+ {
2651
+ return true ;
2652
+ }
2486
2653
if ( m_LocalIDPresent.dirty () )
2487
2654
{
2488
2655
return true ;
@@ -2560,6 +2727,7 @@ void FunctionInfoMetaData::discardChanges()
2560
2727
m_ThreadGroupSize.discardChanges ();
2561
2728
m_ThreadGroupSizeHint.discardChanges ();
2562
2729
m_SubGroupSize.discardChanges ();
2730
+ m_WorkgroupWalkOrder.discardChanges ();
2563
2731
m_LocalIDPresent.discardChanges ();
2564
2732
m_GroupIDPresent.discardChanges ();
2565
2733
m_GlobalOffsetPresent.discardChanges ();
@@ -2617,6 +2785,11 @@ llvm::Metadata* FunctionInfoMetaData::generateNode(llvm::LLVMContext& context) c
2617
2785
args.push_back (m_SubGroupSize.generateNode (context));
2618
2786
}
2619
2787
2788
+ if (m_WorkgroupWalkOrder->hasValue ())
2789
+ {
2790
+ args.push_back (m_WorkgroupWalkOrder.generateNode (context));
2791
+ }
2792
+
2620
2793
if (isLocalIDPresentHasValue ())
2621
2794
{
2622
2795
args.push_back (m_LocalIDPresent.generateNode (context));
@@ -2731,6 +2904,7 @@ void FunctionInfoMetaData::save(llvm::LLVMContext& context, llvm::MDNode* pNode)
2731
2904
m_ThreadGroupSize.save (context, llvm::cast<llvm::MDNode>(getThreadGroupSizeNode (pNode)));
2732
2905
m_ThreadGroupSizeHint.save (context, llvm::cast<llvm::MDNode>(getThreadGroupSizeHintNode (pNode)));
2733
2906
m_SubGroupSize.save (context, llvm::cast<llvm::MDNode>(getSubGroupSizeNode (pNode)));
2907
+ m_WorkgroupWalkOrder.save (context, llvm::cast<llvm::MDNode>(getSubGroupSizeNode (pNode)));
2734
2908
m_LocalIDPresent.save (context, llvm::cast<llvm::MDNode>(getLocalIDPresentNode (pNode)));
2735
2909
m_GroupIDPresent.save (context, llvm::cast<llvm::MDNode>(getGroupIDPresentNode (pNode)));
2736
2910
m_GlobalOffsetPresent.save (context, llvm::cast<llvm::MDNode>(getGlobalOffsetPresentNode (pNode)));
@@ -2857,6 +3031,24 @@ llvm::MDNode* FunctionInfoMetaData::getSubGroupSizeNode( const llvm::MDNode* pPa
2857
3031
}
2858
3032
return NULL ;
2859
3033
}
3034
+
3035
+ llvm::MDNode* FunctionInfoMetaData::getWorkgroupWalkOrderNode (const llvm::MDNode* pParentNode) const
3036
+ {
3037
+ if (!pParentNode)
3038
+ {
3039
+ return NULL ;
3040
+ }
3041
+
3042
+ unsigned int offset = _Mybase::getStartIndex ();
3043
+ for (NodeIterator i = NodeIterator (pParentNode, 0 + offset), e = NodeIterator (pParentNode); i != e; ++i)
3044
+ {
3045
+ if (isNamedNode (i.get (), " sub_group_size" ))
3046
+ {
3047
+ return llvm::dyn_cast<llvm::MDNode>(i.get ());
3048
+ }
3049
+ }
3050
+ return NULL ;
3051
+ }
2860
3052
2861
3053
llvm::Metadata* FunctionInfoMetaData::getLocalIDPresentNode ( const llvm::MDNode* pParentNode) const
2862
3054
{
0 commit comments