File: MetaDataApi.h

package info (click to toggle)
intel-graphics-compiler 1.0.12504.6-1%2Bdeb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 83,912 kB
  • sloc: cpp: 910,147; lisp: 202,655; ansic: 15,197; python: 4,025; yacc: 2,241; lex: 1,570; pascal: 244; sh: 104; makefile: 25
file content (1120 lines) | stat: -rw-r--r-- 36,688 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
/*========================== begin_copyright_notice ============================

Copyright (C) 2017-2021 Intel Corporation

SPDX-License-Identifier: MIT

============================= end_copyright_notice ===========================*/

#pragma once

#include "MetaDataApiUtils.h"
#include "MDFrameWork.h"

namespace IGC {
    namespace IGCMD
    {
        //typedefs and forward declarations
        class ArgInfoMetaData;
        typedef MetaObjectHandle<ArgInfoMetaData> ArgInfoMetaDataHandle;

        class SubGroupSizeMetaData;
        typedef MetaObjectHandle<SubGroupSizeMetaData> SubGroupSizeMetaDataHandle;

        class VectorTypeHintMetaData;
        typedef MetaObjectHandle<VectorTypeHintMetaData> VectorTypeHintMetaDataHandle;

        class ThreadGroupSizeMetaData;
        typedef MetaObjectHandle<ThreadGroupSizeMetaData> ThreadGroupSizeMetaDataHandle;

        class FunctionInfoMetaData;
        typedef MetaObjectHandle<FunctionInfoMetaData> FunctionInfoMetaDataHandle;

        typedef MetaDataList<ArgInfoMetaDataHandle> ArgInfoListMetaDataList;
        typedef MetaObjectHandle<ArgInfoListMetaDataList> ArgInfoListMetaDataListHandle;

        ///
        // Read/Write the ArgInfo structure from/to LLVM metadata
        //
        class ArgInfoMetaData :public IMetaDataObject
        {
        public:
            typedef ArgInfoMetaData _Myt;
            typedef IMetaDataObject _Mybase;
            // typedefs for data member types
            typedef MetaDataValue<int32_t>::value_type ArgIdType;
            typedef NamedMetaDataValue<int32_t>::value_type ExplicitArgNumType;
            typedef NamedMetaDataValue<int32_t>::value_type StructArgOffsetType;
            typedef NamedMetaDataValue<bool>::value_type ImgAccessFloatCoordsType;
            typedef NamedMetaDataValue<bool>::value_type ImgAccessIntCoordsType;

        public:
            ///
            // Factory method - creates the ArgInfoMetaData from the given metadata node
            //
            static _Myt* get(const llvm::MDNode* pNode, bool hasId = false)
            {
                return new _Myt(pNode, hasId);
            }

            ///
            // Factory method - create the default empty ArgInfoMetaData object
            static _Myt* get()
            {
                return new _Myt();
            }

            ///
            // Factory method - create the default empty named ArgInfoMetaData object
            static _Myt* get(const char* name)
            {
                return new _Myt(name);
            }

            ///
            // Ctor - loads the ArgInfoMetaData from the given metadata node
            //
            ArgInfoMetaData(const llvm::MDNode* pNode, bool hasId);

            ///
            // Default Ctor - creates the empty, not named ArgInfoMetaData object
            //
            ArgInfoMetaData();

            ///
            // Ctor - creates the empty, named ArgInfoMetaData object
            //
            ArgInfoMetaData(const char* name);

            /// ArgId related methods
            ArgIdType getArgId() const
            {
                return m_ArgId.get();
            }
            void setArgId(const ArgIdType& val)
            {
                m_ArgId.set(val);
            }
            bool isArgIdHasValue() const
            {
                return m_ArgId.hasValue();
            }


            /// ExplicitArgNum related methods
            ExplicitArgNumType getExplicitArgNum() const
            {
                return m_ExplicitArgNum.get();
            }
            void setExplicitArgNum(const ExplicitArgNumType& val)
            {
                m_ExplicitArgNum.set(val);
            }
            bool isExplicitArgNumHasValue() const
            {
                return m_ExplicitArgNum.hasValue();
            }


            /// StructArgOffset related methods
            StructArgOffsetType getStructArgOffset() const
            {
                return m_StructArgOffset.get();
            }
            void setStructArgOffset(const StructArgOffsetType& val)
            {
                m_StructArgOffset.set(val);
            }
            bool isStructArgOffsetHasValue() const
            {
                return m_StructArgOffset.hasValue();
            }


            /// ImgAccessFloatCoords related methods
            ImgAccessFloatCoordsType getImgAccessFloatCoords() const
            {
                return m_ImgAccessFloatCoords.get();
            }
            void setImgAccessFloatCoords(const ImgAccessFloatCoordsType& val)
            {
                m_ImgAccessFloatCoords.set(val);
            }
            bool isImgAccessFloatCoordsHasValue() const
            {
                return m_ImgAccessFloatCoords.hasValue();
            }


            /// ImgAccessIntCoords related methods
            ImgAccessIntCoordsType getImgAccessIntCoords() const
            {
                return m_ImgAccessIntCoords.get();
            }
            void setImgAccessIntCoords(const ImgAccessIntCoordsType& val)
            {
                m_ImgAccessIntCoords.set(val);
            }
            bool isImgAccessIntCoordsHasValue() const
            {
                return m_ImgAccessIntCoords.hasValue();
            }

            ///
            // Returns true if any of the ArgInfoMetaData`s members has changed
            bool dirty() const;

            ///
            // Returns true if the structure was loaded from the metadata or was changed
            bool hasValue() const;

            ///
            // Discards the changes done to the ArgInfoMetaData instance
            void discardChanges();

            ///
            // Generates the new MDNode hierarchy for the given structure
            llvm::Metadata* generateNode(llvm::LLVMContext& context) const;

            ///
            // Saves the structure changes to the given MDNode
            void save(llvm::LLVMContext& context, llvm::MDNode* pNode) const;

        private:
            ///
            // Returns true if the given MDNode could be saved to without replacement
            bool compatibleWith(const llvm::MDNode* pNode) const
            {
                IGC_UNUSED(pNode);
                return false;
            }

        private:
            typedef MetaDataIterator<llvm::MDNode> NodeIterator;

            llvm::Metadata* getArgIdNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getExplicitArgNumNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getStructArgOffsetNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getImgAccessFloatCoordsNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getImgAccessIntCoordsNode(const llvm::MDNode* pParentNode) const;

        private:
            // data members
            MetaDataValue<int32_t> m_ArgId;
            NamedMetaDataValue<int32_t> m_ExplicitArgNum;
            NamedMetaDataValue<int32_t> m_StructArgOffset;
            NamedMetaDataValue<bool> m_ImgAccessFloatCoords;
            NamedMetaDataValue<bool> m_ImgAccessIntCoords;
            // parent node
            const llvm::MDNode* m_pNode;
        };

        ///
        // Read/Write the ArgDependencyInfo structure from/to LLVM metadata
        //
        class ArgDependencyInfoMetaData :public IMetaDataObject
        {
        public:
            typedef ArgDependencyInfoMetaData _Myt;
            typedef IMetaDataObject _Mybase;
            // typedefs for data member types
            typedef MetaDataValue<std::string>::value_type ArgType;
            typedef MetaDataValue<int32_t>::value_type ArgDependencyType;

        public:
            ///
            // Factory method - creates the ArgDependencyInfoMetaData from the given metadata node
            //
            static _Myt* get(const llvm::MDNode* pNode, bool hasId = false)
            {
                return new _Myt(pNode, hasId);
            }

            ///
            // Factory method - create the default empty ArgDependencyInfoMetaData object
            static _Myt* get()
            {
                return new _Myt();
            }

            ///
            // Factory method - create the default empty named ArgDependencyInfoMetaData object
            static _Myt* get(const char* name)
            {
                return new _Myt(name);
            }

            ///
            // Ctor - loads the ArgDependencyInfoMetaData from the given metadata node
            //
            ArgDependencyInfoMetaData(const llvm::MDNode* pNode, bool hasId);

            ///
            // Default Ctor - creates the empty, not named ArgDependencyInfoMetaData object
            //
            ArgDependencyInfoMetaData();

            ///
            // Ctor - creates the empty, named ArgDependencyInfoMetaData object
            //
            ArgDependencyInfoMetaData(const char* name);

            /// Arg related methods
            ArgType getArg() const
            {
                return m_Arg.get();
            }
            void setArg(const ArgType& val)
            {
                m_Arg.set(val);
            }
            bool isArgHasValue() const
            {
                return m_Arg.hasValue();
            }


            /// ArgDependency related methods
            ArgDependencyType getArgDependency() const
            {
                return m_ArgDependency.get();
            }
            void setArgDependency(const ArgDependencyType& val)
            {
                m_ArgDependency.set(val);
            }
            bool isArgDependencyHasValue() const
            {
                return m_ArgDependency.hasValue();
            }

            ///
            // Returns true if any of the ArgDependencyInfoMetaData`s members has changed
            bool dirty() const;

            ///
            // Returns true if the structure was loaded from the metadata or was changed
            bool hasValue() const;

            ///
            // Discards the changes done to the ArgDependencyInfoMetaData instance
            void discardChanges();

            ///
            // Generates the new MDNode hierarchy for the given structure
            llvm::Metadata* generateNode(llvm::LLVMContext& context) const;

            ///
            // Saves the structure changes to the given MDNode
            void save(llvm::LLVMContext& context, llvm::MDNode* pNode) const;

        private:
            ///
            // Returns true if the given MDNode could be saved to without replacement
            bool compatibleWith(const llvm::MDNode* pNode) const
            {
                IGC_UNUSED(pNode);
                return false;
            }

        private:
            typedef MetaDataIterator<llvm::MDNode> NodeIterator;

            llvm::Metadata* getArgNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getArgDependencyNode(const llvm::MDNode* pParentNode) const;

        private:
            // data members
            MetaDataValue<std::string> m_Arg;
            MetaDataValue<int32_t> m_ArgDependency;
            // parent node
            const llvm::MDNode* m_pNode;
        };

        ///
        // Read/Write the SubGroupSize structure from/to LLVM metadata
        //
        class SubGroupSizeMetaData :public IMetaDataObject
        {
        public:
            typedef SubGroupSizeMetaData _Myt;
            typedef IMetaDataObject _Mybase;
            // typedefs for data member types
            typedef MetaDataValue<int32_t>::value_type SIMD_sizeType;

        public:
            ///
            // Factory method - creates the SubGroupSizeMetaData from the given metadata node
            //
            static _Myt* get(const llvm::MDNode* pNode, bool hasId = false)
            {
                return new _Myt(pNode, hasId);
            }

            ///
            // Factory method - create the default empty SubGroupSizeMetaData object
            static _Myt* get()
            {
                return new _Myt();
            }

            ///
            // Factory method - create the default empty named SubGroupSizeMetaData object
            static _Myt* get(const char* name)
            {
                return new _Myt(name);
            }

            ///
            // Ctor - loads the SubGroupSizeMetaData from the given metadata node
            //
            SubGroupSizeMetaData(const llvm::MDNode* pNode, bool hasId);

            ///
            // Default Ctor - creates the empty, not named SubGroupSizeMetaData object
            //
            SubGroupSizeMetaData();

            ///
            // Ctor - creates the empty, named SubGroupSizeMetaData object
            //
            SubGroupSizeMetaData(const char* name);

            /// SIMD_size related methods
            SIMD_sizeType getSIMD_size() const
            {
                return m_SIMD_size.get();
            }
            void setSIMD_size(const SIMD_sizeType& val)
            {
                m_SIMD_size.set(val);
            }
            bool isSIMD_sizeHasValue() const
            {
                return m_SIMD_size.hasValue();
            }

            ///
            // Returns true if any of the SubGroupSizeMetaData`s members has changed
            bool dirty() const;

            ///
            // Returns true if the structure was loaded from the metadata or was changed
            bool hasValue() const;

            ///
            // Discards the changes done to the SubGroupSizeMetaData instance
            void discardChanges();

            ///
            // Generates the new MDNode hierarchy for the given structure
            llvm::Metadata* generateNode(llvm::LLVMContext& context) const;

            ///
            // Saves the structure changes to the given MDNode
            void save(llvm::LLVMContext& context, llvm::MDNode* pNode) const;

        private:
            ///
            // Returns true if the given MDNode could be saved to without replacement
            bool compatibleWith(const llvm::MDNode* pNode) const
            {
                IGC_UNUSED(pNode);
                return false;
            }

        private:
            typedef MetaDataIterator<llvm::MDNode> NodeIterator;

            llvm::Metadata* getSIMD_sizeNode(const llvm::MDNode* pParentNode) const;

        private:
            // data members
            MetaDataValue<int32_t> m_SIMD_size;
            // parent node
            const llvm::MDNode* m_pNode;
        };

        ///
        // Read/Write the VectorTypeHint structure from/to LLVM metadata
        //
        class VectorTypeHintMetaData :public IMetaDataObject
        {
        public:
            typedef VectorTypeHintMetaData _Myt;
            typedef IMetaDataObject _Mybase;
            // typedefs for data member types
            typedef MetaDataValue<llvm::UndefValue>::value_type VecTypeType;
            typedef MetaDataValue<bool>::value_type SignType;

        public:
            ///
            // Factory method - creates the VectorTypeHintMetaData from the given metadata node
            //
            static _Myt* get(const llvm::MDNode* pNode, bool hasId = false)
            {
                return new _Myt(pNode, hasId);
            }

            ///
            // Factory method - create the default empty VectorTypeHintMetaData object
            static _Myt* get()
            {
                return new _Myt();
            }

            ///
            // Factory method - create the default empty named VectorTypeHintMetaData object
            static _Myt* get(const char* name)
            {
                return new _Myt(name);
            }

            ///
            // Ctor - loads the VectorTypeHintMetaData from the given metadata node
            //
            VectorTypeHintMetaData(const llvm::MDNode* pNode, bool hasId);

            ///
            // Default Ctor - creates the empty, not named VectorTypeHintMetaData object
            //
            VectorTypeHintMetaData();

            ///
            // Ctor - creates the empty, named VectorTypeHintMetaData object
            //
            VectorTypeHintMetaData(const char* name);

            /// VecType related methods
            VecTypeType getVecType() const
            {
                return m_VecType.get();
            }
            void setVecType(const VecTypeType& val)
            {
                m_VecType.set(val);
            }
            bool isVecTypeHasValue() const
            {
                return m_VecType.hasValue();
            }


            /// Sign related methods
            SignType getSign() const
            {
                return m_Sign.get();
            }
            void setSign(const SignType& val)
            {
                m_Sign.set(val);
            }
            bool isSignHasValue() const
            {
                return m_Sign.hasValue();
            }

            ///
            // Returns true if any of the VectorTypeHintMetaData`s members has changed
            bool dirty() const;

            ///
            // Returns true if the structure was loaded from the metadata or was changed
            bool hasValue() const;

            ///
            // Discards the changes done to the VectorTypeHintMetaData instance
            void discardChanges();

            ///
            // Generates the new MDNode hierarchy for the given structure
            llvm::Metadata* generateNode(llvm::LLVMContext& context) const;

            ///
            // Saves the structure changes to the given MDNode
            void save(llvm::LLVMContext& context, llvm::MDNode* pNode) const;

        private:
            ///
            // Returns true if the given MDNode could be saved to without replacement
            bool compatibleWith(const llvm::MDNode* pNode) const
            {
                IGC_UNUSED(pNode);
                return false;
            }

        private:
            typedef MetaDataIterator<llvm::MDNode> NodeIterator;

            llvm::Metadata* getVecTypeNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getSignNode(const llvm::MDNode* pParentNode) const;

        private:
            // data members
            MetaDataValue<llvm::UndefValue> m_VecType;
            MetaDataValue<bool> m_Sign;
            // parent node
            const llvm::MDNode* m_pNode;
        };

        ///
        // Read/Write the ThreadGroupSize structure from/to LLVM metadata
        //
        class ThreadGroupSizeMetaData :public IMetaDataObject
        {
        public:
            typedef ThreadGroupSizeMetaData _Myt;
            typedef IMetaDataObject _Mybase;
            // typedefs for data member types
            typedef MetaDataValue<int32_t>::value_type XDimType;
            typedef MetaDataValue<int32_t>::value_type YDimType;
            typedef MetaDataValue<int32_t>::value_type ZDimType;

        public:
            ///
            // Factory method - creates the ThreadGroupSizeMetaData from the given metadata node
            //
            static _Myt* get(const llvm::MDNode* pNode, bool hasId = false)
            {
                return new _Myt(pNode, hasId);
            }

            ///
            // Factory method - create the default empty ThreadGroupSizeMetaData object
            static _Myt* get()
            {
                return new _Myt();
            }

            ///
            // Factory method - create the default empty named ThreadGroupSizeMetaData object
            static _Myt* get(const char* name)
            {
                return new _Myt(name);
            }

            ///
            // Ctor - loads the ThreadGroupSizeMetaData from the given metadata node
            //
            ThreadGroupSizeMetaData(const llvm::MDNode* pNode, bool hasId);

            ///
            // Default Ctor - creates the empty, not named ThreadGroupSizeMetaData object
            //
            ThreadGroupSizeMetaData();

            ///
            // Ctor - creates the empty, named ThreadGroupSizeMetaData object
            //
            ThreadGroupSizeMetaData(const char* name);

            /// XDim related methods
            XDimType getXDim() const
            {
                return m_XDim.get();
            }
            void setXDim(const XDimType& val)
            {
                m_XDim.set(val);
            }
            bool isXDimHasValue() const
            {
                return m_XDim.hasValue();
            }


            /// YDim related methods
            YDimType getYDim() const
            {
                return m_YDim.get();
            }
            void setYDim(const YDimType& val)
            {
                m_YDim.set(val);
            }
            bool isYDimHasValue() const
            {
                return m_YDim.hasValue();
            }


            /// ZDim related methods
            ZDimType getZDim() const
            {
                return m_ZDim.get();
            }
            void setZDim(const ZDimType& val)
            {
                m_ZDim.set(val);
            }
            bool isZDimHasValue() const
            {
                return m_ZDim.hasValue();
            }

            ///
            // Returns true if any of the ThreadGroupSizeMetaData`s members has changed
            bool dirty() const;

            ///
            // Returns true if the structure was loaded from the metadata or was changed
            bool hasValue() const;

            ///
            // Discards the changes done to the ThreadGroupSizeMetaData instance
            void discardChanges();

            ///
            // Generates the new MDNode hierarchy for the given structure
            llvm::Metadata* generateNode(llvm::LLVMContext& context) const;

            ///
            // Saves the structure changes to the given MDNode
            void save(llvm::LLVMContext& context, llvm::MDNode* pNode) const;

        private:
            ///
            // Returns true if the given MDNode could be saved to without replacement
            bool compatibleWith(const llvm::MDNode* pNode) const
            {
                IGC_UNUSED(pNode);
                return false;
            }

        private:
            typedef MetaDataIterator<llvm::MDNode> NodeIterator;

            llvm::Metadata* getXDimNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getYDimNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getZDimNode(const llvm::MDNode* pParentNode) const;

        private:
            // data members
            MetaDataValue<int32_t> m_XDim;
            MetaDataValue<int32_t> m_YDim;
            MetaDataValue<int32_t> m_ZDim;
            // parent node
            const llvm::MDNode* m_pNode;
        };

        ///
        // Read/Write the FunctionInfo structure from/to LLVM metadata
        //
        class FunctionInfoMetaData :public IMetaDataObject
        {
        public:
            typedef FunctionInfoMetaData _Myt;
            typedef IMetaDataObject _Mybase;
            // typedefs for data member types
            typedef NamedMetaDataValue<int32_t>::value_type TypeType;
            typedef MetaDataList<ArgInfoMetaDataHandle> ArgInfoListList;
            typedef MetaDataList<ArgInfoMetaDataHandle> ImplicitArgInfoListList;
            typedef NamedMetaDataValue<int32_t>::value_type PrivateMemoryPerWIType;

            typedef NamedMetaDataValue<int32_t>::value_type NeedBindlessHandleType;


        public:
            ///
            // Factory method - creates the FunctionInfoMetaData from the given metadata node
            //
            static _Myt* get(const llvm::MDNode* pNode, bool hasId = false)
            {
                return new _Myt(pNode, hasId);
            }

            ///
            // Factory method - create the default empty FunctionInfoMetaData object
            static _Myt* get()
            {
                return new _Myt();
            }

            ///
            // Factory method - create the default empty named FunctionInfoMetaData object
            static _Myt* get(const char* name)
            {
                return new _Myt(name);
            }

            ///
            // Ctor - loads the FunctionInfoMetaData from the given metadata node
            //
            FunctionInfoMetaData(const llvm::MDNode* pNode, bool hasId);

            ///
            // Default Ctor - creates the empty, not named FunctionInfoMetaData object
            //
            FunctionInfoMetaData();

            ///
            // Ctor - creates the empty, named FunctionInfoMetaData object
            //
            FunctionInfoMetaData(const char* name);

            /// Type related methods
            TypeType getType() const
            {
                return m_Type.get();
            }
            void setType(const TypeType& val)
            {
                m_Type.set(val);
            }
            bool isTypeHasValue() const
            {
                return m_Type.hasValue();
            }


            /// ArgInfoList related methods
            ArgInfoListList::iterator begin_ArgInfoList()
            {
                return m_ArgInfoList.begin();
            }

            ArgInfoListList::iterator end_ArgInfoList()
            {
                return m_ArgInfoList.end();
            }
            ArgInfoListList::const_iterator begin_ArgInfoList() const
            {
                return m_ArgInfoList.begin();
            }

            ArgInfoListList::const_iterator end_ArgInfoList() const
            {
                return m_ArgInfoList.end();
            }

            size_t size_ArgInfoList()  const
            {
                return m_ArgInfoList.size();
            }

            bool empty_ArgInfoList()  const
            {
                return m_ArgInfoList.empty();
            }

            bool isArgInfoListHasValue() const
            {
                return m_ArgInfoList.hasValue();
            }

            ArgInfoListList::item_type getArgInfoListItem(size_t index) const
            {
                return m_ArgInfoList.getItem(index);
            }
            void clearArgInfoList()
            {
                m_ArgInfoList.clear();
            }

            void setArgInfoListItem(size_t index, const ArgInfoListList::item_type& item)
            {
                return m_ArgInfoList.setItem(index, item);
            }

            void addArgInfoListItem(const ArgInfoListList::item_type& val)
            {
                m_ArgInfoList.push_back(val);
            }

            ArgInfoListList::iterator eraseArgInfoListItem(ArgInfoListList::iterator i)
            {
                return m_ArgInfoList.erase(i);
            }


            /// ImplicitArgInfoList related methods
            ImplicitArgInfoListList::iterator begin_ImplicitArgInfoList()
            {
                return m_ImplicitArgInfoList.begin();
            }

            ImplicitArgInfoListList::iterator end_ImplicitArgInfoList()
            {
                return m_ImplicitArgInfoList.end();
            }
            ImplicitArgInfoListList::const_iterator begin_ImplicitArgInfoList() const
            {
                return m_ImplicitArgInfoList.begin();
            }

            ImplicitArgInfoListList::const_iterator end_ImplicitArgInfoList() const
            {
                return m_ImplicitArgInfoList.end();
            }

            size_t size_ImplicitArgInfoList()  const
            {
                return m_ImplicitArgInfoList.size();
            }

            bool empty_ImplicitArgInfoList()  const
            {
                return m_ImplicitArgInfoList.empty();
            }

            bool isImplicitArgInfoListHasValue() const
            {
                return m_ImplicitArgInfoList.hasValue();
            }

            ImplicitArgInfoListList::item_type getImplicitArgInfoListItem(size_t index) const
            {
                return m_ImplicitArgInfoList.getItem(index);
            }

            void clearImplicitArgInfoList()
            {
                m_ImplicitArgInfoList.clear();
            }

            void setImplicitArgInfoListItem(size_t index, const ImplicitArgInfoListList::item_type& item)
            {
                return m_ImplicitArgInfoList.setItem(index, item);
            }

            void addImplicitArgInfoListItem(const ImplicitArgInfoListList::item_type& val)
            {
                m_ImplicitArgInfoList.push_back(val);
            }

            ImplicitArgInfoListList::iterator eraseImplicitArgInfoListItem(ImplicitArgInfoListList::iterator i)
            {
                return m_ImplicitArgInfoList.erase(i);
            }


            /// ThreadGroupSize related methods

            ThreadGroupSizeMetaDataHandle getThreadGroupSize()
            {
                return m_ThreadGroupSize;
            }


            /// ThreadGroupSizeHint related methods

            ThreadGroupSizeMetaDataHandle getThreadGroupSizeHint()
            {
                return m_ThreadGroupSizeHint;
            }


            /// SubGroupSize related methods

            SubGroupSizeMetaDataHandle getSubGroupSize()
            {
                return m_SubGroupSize;
            }

            /// OpenCLVectorTypeHint related methods

            VectorTypeHintMetaDataHandle getOpenCLVectorTypeHint()
            {
                return m_OpenCLVectorTypeHint;
            }

            ///
            // Returns true if any of the FunctionInfoMetaData`s members has changed
            bool dirty() const;

            ///
            // Returns true if the structure was loaded from the metadata or was changed
            bool hasValue() const;

            ///
            // Discards the changes done to the FunctionInfoMetaData instance
            void discardChanges();

            ///
            // Generates the new MDNode hierarchy for the given structure
            llvm::Metadata* generateNode(llvm::LLVMContext& context) const;

            ///
            // Saves the structure changes to the given MDNode
            void save(llvm::LLVMContext& context, llvm::MDNode* pNode) const;

        private:
            ///
            // Returns true if the given MDNode could be saved to without replacement
            bool compatibleWith(const llvm::MDNode* pNode) const
            {
                IGC_UNUSED(pNode);
                return false;
            }

        private:
            typedef MetaDataIterator<llvm::MDNode> NodeIterator;

            llvm::Metadata* getTypeNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getArgInfoListNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getImplicitArgInfoListNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getThreadGroupSizeNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getThreadGroupSizeHintNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getSubGroupSizeNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getWorkgroupWalkOrderNode(const llvm::MDNode* pParentNode) const;
            llvm::Metadata* getLocalSizeNode(const llvm::MDNode* pParentNode) const;
            llvm::MDNode* getOpenCLVectorTypeHintNode(const llvm::MDNode* pParentNode) const;

        private:
            // data members
            NamedMetaDataValue<int32_t> m_Type;
            MetaDataList<ArgInfoMetaDataHandle> m_ArgInfoList;
            MetaDataList<ArgInfoMetaDataHandle> m_ImplicitArgInfoList;
            ThreadGroupSizeMetaDataHandle m_ThreadGroupSize;
            ThreadGroupSizeMetaDataHandle m_ThreadGroupSizeHint;
            SubGroupSizeMetaDataHandle m_SubGroupSize;

            VectorTypeHintMetaDataHandle m_OpenCLVectorTypeHint;
            // parent node
            const llvm::MDNode* m_pNode;
        };

        class MetaDataUtils
        {
        public:
            // typedefs for the data members types
            typedef NamedMetaDataMap<llvm::Function, FunctionInfoMetaDataHandle> FunctionsInfoMap;

        public:
            // If using this constructor, setting the llvm module by the setModule
            // function is needed for correct operation.
            MetaDataUtils() {}
            MetaDataUtils(llvm::Module* pModule) :
                m_FunctionsInfo(pModule->getOrInsertNamedMetadata("igc.functions")),
                m_pModule(pModule)
            {
            }

            void setModule(llvm::Module* pModule) {
                m_FunctionsInfo = pModule->getOrInsertNamedMetadata("igc.functions");
                m_pModule = pModule;
            }

            ~MetaDataUtils() {}

            /// FunctionsInfo related methods
            void clearFunctionsInfo()
            {
                m_FunctionsInfo.clear();
            }

            void deleteFunctionsInfo()
            {
                llvm::NamedMDNode* FunctionsInfoNode = m_pModule->getNamedMetadata("igc.functions");
                if (FunctionsInfoNode)
                {
                    m_nodesToDelete.push_back(FunctionsInfoNode);
                }
            }

            FunctionsInfoMap::iterator begin_FunctionsInfo()
            {
                return m_FunctionsInfo.begin();
            }

            FunctionsInfoMap::iterator end_FunctionsInfo()
            {
                return m_FunctionsInfo.end();
            }

            FunctionsInfoMap::const_iterator begin_FunctionsInfo() const
            {
                return m_FunctionsInfo.begin();
            }

            FunctionsInfoMap::const_iterator end_FunctionsInfo() const
            {
                return m_FunctionsInfo.end();
            }

            size_t size_FunctionsInfo() const
            {
                return m_FunctionsInfo.size();
            }

            bool empty_FunctionsInfo() const
            {
                return m_FunctionsInfo.empty();
            }

            bool isFunctionsInfoHasValue() const
            {
                return m_FunctionsInfo.hasValue();
            }

            FunctionsInfoMap::item_type getFunctionsInfoItem(const FunctionsInfoMap::key_type& index) const
            {
                return m_FunctionsInfo.getItem(index);
            }

            FunctionsInfoMap::item_type getOrInsertFunctionsInfoItem(const FunctionsInfoMap::key_type& index)
            {
                return m_FunctionsInfo.getOrInsertItem(index);
            }

            void setFunctionsInfoItem(const FunctionsInfoMap::key_type& index, const FunctionsInfoMap::item_type& item)
            {
                return m_FunctionsInfo.setItem(index, item);
            }

            FunctionsInfoMap::iterator findFunctionsInfoItem(const FunctionsInfoMap::key_type& key)
            {
                return m_FunctionsInfo.find(key);
            }
            FunctionsInfoMap::const_iterator findFunctionsInfoItem(const FunctionsInfoMap::key_type& key) const
            {
                return m_FunctionsInfo.find(key);
            }

            void eraseFunctionsInfoItem(FunctionsInfoMap::iterator it)
            {
                m_FunctionsInfo.erase(it);
            }

            void save(llvm::LLVMContext& context)
            {
                if (m_FunctionsInfo.dirty())
                {
                    llvm::NamedMDNode* pNode = m_pModule->getOrInsertNamedMetadata("igc.functions");
                    m_FunctionsInfo.save(context, pNode);
                }

                for (auto node : m_nodesToDelete)
                {
                    m_pModule->eraseNamedMetadata(node);
                }
                m_nodesToDelete.clear();

                discardChanges();
            }

            void discardChanges()
            {
                m_FunctionsInfo.discardChanges();
                m_nodesToDelete.clear();
            }

            void deleteMetadata()
            {
                llvm::NamedMDNode* FunctionsInfoNode = m_pModule->getNamedMetadata("igc.functions");
                if (FunctionsInfoNode)
                {
                    m_nodesToDelete.push_back(FunctionsInfoNode);
                }
            }

        private:
            // data members
            NamedMetaDataMap<llvm::Function, FunctionInfoMetaDataHandle> m_FunctionsInfo;
            llvm::Module* m_pModule;
            std::vector<llvm::NamedMDNode*> m_nodesToDelete;
        };


    }
} //namespace