LLVM  16.0.0git
PluginLoader.cpp
Go to the documentation of this file.
1 //===-- PluginLoader.cpp - Implement -load command line option ------------===//
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 // This file implements the -load <plugin> command line option handler.
10 //
11 //===----------------------------------------------------------------------===//
12 
13 #define DONT_GET_PLUGIN_LOADER_OPTION
16 #include "llvm/Support/Mutex.h"
18 #include <vector>
19 using namespace llvm;
20 
21 namespace {
22 
23 struct Plugins {
25  std::vector<std::string> List;
26 };
27 
28 Plugins &getPlugins() {
29  static Plugins P;
30  return P;
31 }
32 
33 } // anonymous namespace
34 
35 void PluginLoader::operator=(const std::string &Filename) {
36  auto &P = getPlugins();
37  sys::SmartScopedLock<true> Lock(P.Lock);
38  std::string Error;
39  if (sys::DynamicLibrary::LoadLibraryPermanently(Filename.c_str(), &Error)) {
40  errs() << "Error opening '" << Filename << "': " << Error
41  << "\n -load request ignored.\n";
42  } else {
43  P.List.push_back(Filename);
44  }
45 }
46 
48  auto &P = getPlugins();
49  sys::SmartScopedLock<true> Lock(P.Lock);
50  return P.List.size();
51 }
52 
53 std::string &PluginLoader::getPlugin(unsigned num) {
54  auto &P = getPlugins();
55  sys::SmartScopedLock<true> Lock(P.Lock);
56  assert(num < P.List.size() && "Asking for an out of bounds plugin");
57  return P.List[num];
58 }
PluginLoader.h
llvm
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
P
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
Definition: README-SSE.txt:411
DynamicLibrary.h
llvm::errs
raw_fd_ostream & errs()
This returns a reference to a raw_ostream for standard error.
Definition: raw_ostream.cpp:893
llvm::sys::SmartMutex
SmartMutex - A mutex with a compile time constant parameter that indicates whether this mutex should ...
Definition: Mutex.h:28
llvm::PluginLoader::getNumPlugins
static unsigned getNumPlugins()
Definition: PluginLoader.cpp:47
llvm::sys::SmartScopedLock
std::lock_guard< SmartMutex< mt_only > > SmartScopedLock
Definition: Mutex.h:69
assert
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
llvm::PluginLoader::operator=
void operator=(const std::string &Filename)
Definition: PluginLoader.cpp:35
Mutex.h
llvm::Error
Lightweight error class with error context and mandatory checking.
Definition: Error.h:155
List
const NodeList & List
Definition: RDFGraph.cpp:199
llvm::sys::DynamicLibrary::LoadLibraryPermanently
static bool LoadLibraryPermanently(const char *Filename, std::string *ErrMsg=nullptr)
This function permanently loads the dynamic library at the given path.
Definition: DynamicLibrary.h:85
raw_ostream.h
llvm::PluginLoader::getPlugin
static std::string & getPlugin(unsigned num)
Definition: PluginLoader.cpp:53