xref: /llvm-project/llvm/lib/SandboxIR/Module.cpp (revision 7e5df5bcc3be3299a0aa3a2c65f81b794c5ba935)
1 //===- Module.cpp ---------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
8 
9 #include "llvm/SandboxIR/Module.h"
10 #include "llvm/SandboxIR/SandboxIR.h"
11 
12 using namespace llvm::sandboxir;
13 
14 Function *Module::getFunction(StringRef Name) const {
15   llvm::Function *LLVMF = LLVMM.getFunction(Name);
16   return cast_or_null<Function>(Ctx.getValue(LLVMF));
17 }
18 
19 GlobalVariable *Module::getGlobalVariable(StringRef Name,
20                                           bool AllowInternal) const {
21   return cast_or_null<GlobalVariable>(
22       Ctx.getValue(LLVMM.getGlobalVariable(Name, AllowInternal)));
23 }
24 
25 GlobalAlias *Module::getNamedAlias(StringRef Name) const {
26   return cast_or_null<GlobalAlias>(Ctx.getValue(LLVMM.getNamedAlias(Name)));
27 }
28 
29 GlobalIFunc *Module::getNamedIFunc(StringRef Name) const {
30   return cast_or_null<GlobalIFunc>(Ctx.getValue(LLVMM.getNamedIFunc(Name)));
31 }
32 
33 #ifndef NDEBUG
34 void Module::dumpOS(raw_ostream &OS) const { OS << LLVMM; }
35 
36 void Module::dump() const {
37   dumpOS(dbgs());
38   dbgs() << "\n";
39 }
40 #endif // NDEBUG
41