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 getFunction(StringRef Name) const17Function *Module::getFunction(StringRef Name) const { 18 llvm::Function *LLVMF = LLVMM.getFunction(Name); 19 return cast_or_null<Function>(Ctx.getValue(LLVMF)); 20 } 21 getGlobalVariable(StringRef Name,bool AllowInternal) const22GlobalVariable *Module::getGlobalVariable(StringRef Name, 23 bool AllowInternal) const { 24 return cast_or_null<GlobalVariable>( 25 Ctx.getValue(LLVMM.getGlobalVariable(Name, AllowInternal))); 26 } 27 getNamedAlias(StringRef Name) const28GlobalAlias *Module::getNamedAlias(StringRef Name) const { 29 return cast_or_null<GlobalAlias>(Ctx.getValue(LLVMM.getNamedAlias(Name))); 30 } 31 getNamedIFunc(StringRef Name) const32GlobalIFunc *Module::getNamedIFunc(StringRef Name) const { 33 return cast_or_null<GlobalIFunc>(Ctx.getValue(LLVMM.getNamedIFunc(Name))); 34 } 35 36 #ifndef NDEBUG dumpOS(raw_ostream & OS) const37void Module::dumpOS(raw_ostream &OS) const { OS << LLVMM; } 38 dump() const39void Module::dump() const { 40 dumpOS(dbgs()); 41 dbgs() << "\n"; 42 } 43 #endif // NDEBUG 44