File: MetaDataUtilsWrapper.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 (67 lines) | stat: -rw-r--r-- 2,371 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
/*========================== begin_copyright_notice ============================

Copyright (C) 2017-2021 Intel Corporation

SPDX-License-Identifier: MIT

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

#pragma once

#include "Compiler/MetaDataApi/MetaDataApi.h"

#include "common/LLVMWarningsPush.hpp"
#include <llvm/Pass.h>
#include "common/LLVMWarningsPop.hpp"
#include "common/MDFrameWork.h"

namespace IGC
{
    // This pass provides access to the metadata api.
    //
    // To use this from within another pass:
    //  1. Add MetaDataUtilsWrapper to the analysis usage of the pass:
    //      virtual void getAnalysisUsage(llvm::AnalysisUsage &AU) const override {AU.addRequired<MetaDataUtilsWrapper>();}
    //  2. Add MetaDataUtilsWrapper as a dependency of the pass:
    //      IGC_INITIALIZE_PASS_DEPENDENCY(MetaDataUtilsWrapper)
    //  3. Use getAnalysis on MetaDataUtilsWrapper:
    //      MetaDataUtilsWrapper &mduw = getAnalysis<MetaDataUtilsWrapper>();
    //  4. Get the MetaDataUtils:
    //      MetaDataUtils *mdUtils = mduw.getMetaDataUtils();
    class MetaDataUtilsWrapper : public llvm::ImmutablePass
    {
    public:
        static char ID;

        // Constructs a wrapper to an uninitialized MetaDataUtils instance.
        // To complete initialization, a module must be passed to MetaDataUtils by
        // calling getMetaDataUtils()->setModule(), or by making sure that
        // MetaDataUtilsWrapperInitializer pass runs before using the MetaDataUtils.
        //
        // MetaDataUtilsWrapper will be the owner of the MetaDataUtils, and will be
        // responsible for freeing the allocated memory.
        MetaDataUtilsWrapper();

        // Constructs a wrapper to the given MetaDataUtils instance.
        //
        // MetaDataUtilsWrapper will NOT be the owner of the MetaDataUtils.
        MetaDataUtilsWrapper(IGCMD::MetaDataUtils* pMdUtils, ModuleMetaData* moduleMD = nullptr);

        ~MetaDataUtilsWrapper();

        IGCMD::MetaDataUtils* getMetaDataUtils();
        ModuleMetaData* getModuleMetaData();

        virtual llvm::StringRef getPassName() const override
        {
            return "MetaData Utils Wrapper";
        }

    private:
        IGCMD::MetaDataUtils* m_pMdUtils;
        IGC::ModuleMetaData* modMD;
        bool m_isUtilsOwner;

    };

} // namespace IGC