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