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