Format C++ at 4 columns

Change clang-format settings to indent with 4 spaces instead of 2.
pull/831/head
Andre Masella 2022-04-12 10:15:15 -04:00
parent 0eb153faed
commit 5ec3cc0204
15 changed files with 1665 additions and 1648 deletions

3
.clang-format Normal file
View File

@ -0,0 +1,3 @@
---
BasedOnStyle: LLVM
IndentWidth: 4

View File

@ -15,21 +15,21 @@ extern "C" {
API_EXPORT(LLVMModuleRef)
LLVMPY_ParseAssembly(LLVMContextRef context, const char *ir,
const char **outmsg) {
using namespace llvm;
using namespace llvm;
SMDiagnostic error;
SMDiagnostic error;
Module *m = parseAssemblyString(ir, error, *unwrap(context)).release();
if (!m) {
// Error occurred
std::string osbuf;
raw_string_ostream os(osbuf);
error.print("", os);
os.flush();
*outmsg = LLVMPY_CreateString(os.str().c_str());
return NULL;
}
return wrap(m);
Module *m = parseAssemblyString(ir, error, *unwrap(context)).release();
if (!m) {
// Error occurred
std::string osbuf;
raw_string_ostream os(osbuf);
error.print("", os);
os.flush();
*outmsg = LLVMPY_CreateString(os.str().c_str());
return NULL;
}
return wrap(m);
}
} // end extern "C"

View File

@ -8,23 +8,23 @@ extern "C" {
API_EXPORT(void)
LLVMPY_WriteBitcodeToString(LLVMModuleRef M, const char **outbuf,
size_t *outlen) {
LLVMMemoryBufferRef MB = LLVMWriteBitcodeToMemoryBuffer(M);
*outlen = LLVMGetBufferSize(MB);
*outbuf = LLVMPY_CreateByteString(LLVMGetBufferStart(MB), *outlen);
LLVMDisposeMemoryBuffer(MB);
LLVMMemoryBufferRef MB = LLVMWriteBitcodeToMemoryBuffer(M);
*outlen = LLVMGetBufferSize(MB);
*outbuf = LLVMPY_CreateByteString(LLVMGetBufferStart(MB), *outlen);
LLVMDisposeMemoryBuffer(MB);
}
API_EXPORT(LLVMModuleRef)
LLVMPY_ParseBitcode(LLVMContextRef context, const char *bitcode,
size_t bitcodelen, char **outmsg) {
LLVMModuleRef ref;
LLVMMemoryBufferRef mem = LLVMCreateMemoryBufferWithMemoryRange(
bitcode, bitcodelen, "" /* BufferName*/, 0 /* RequiresNullTerminator*/
);
LLVMModuleRef ref;
LLVMMemoryBufferRef mem = LLVMCreateMemoryBufferWithMemoryRange(
bitcode, bitcodelen, "" /* BufferName*/, 0 /* RequiresNullTerminator*/
);
LLVMParseBitcodeInContext(context, mem, &ref, outmsg);
LLVMDisposeMemoryBuffer(mem);
return ref;
LLVMParseBitcodeInContext(context, mem, &ref, outmsg);
LLVMDisposeMemoryBuffer(mem);
return ref;
}
} // end extern "C"

View File

@ -9,12 +9,12 @@ LLVMPY_CreateString(const char *msg) { return strdup(msg); }
API_EXPORT(const char *)
LLVMPY_CreateByteString(const char *buf, size_t len) {
char *dest = (char *)malloc(len + 1);
if (dest != NULL) {
memcpy(dest, buf, len);
dest[len] = '\0';
}
return dest;
char *dest = (char *)malloc(len + 1);
if (dest != NULL) {
memcpy(dest, buf, len);
dest[len] = '\0';
}
return dest;
}
API_EXPORT(void)
@ -28,13 +28,13 @@ LLVMPY_ContextCreate() { return LLVMContextCreate(); }
API_EXPORT(void)
LLVMPY_ContextDispose(LLVMContextRef context) {
return LLVMContextDispose(context);
return LLVMContextDispose(context);
}
API_EXPORT(void)
LLVMPY_SetCommandLine(const char *name, const char *option) {
const char *argv[] = {name, option};
LLVMParseCommandLineOptions(2, argv, NULL);
const char *argv[] = {name, option};
LLVMParseCommandLineOptions(2, argv, NULL);
}
} // end extern "C"

File diff suppressed because it is too large Load Diff

View File

@ -6,23 +6,23 @@ extern "C" {
API_EXPORT(void *)
LLVMPY_SearchAddressOfSymbol(const char *name) {
return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(name);
return llvm::sys::DynamicLibrary::SearchForAddressOfSymbol(name);
}
API_EXPORT(void)
LLVMPY_AddSymbol(const char *name, void *addr) {
llvm::sys::DynamicLibrary::AddSymbol(name, addr);
llvm::sys::DynamicLibrary::AddSymbol(name, addr);
}
API_EXPORT(bool)
LLVMPY_LoadLibraryPermanently(const char *filename, const char **OutError) {
std::string error;
bool failed =
llvm::sys::DynamicLibrary::LoadLibraryPermanently(filename, &error);
if (failed) {
*OutError = LLVMPY_CreateString(error.c_str());
}
return failed;
std::string error;
bool failed =
llvm::sys::DynamicLibrary::LoadLibraryPermanently(filename, &error);
if (failed) {
*OutError = LLVMPY_CreateString(error.c_str());
}
return failed;
}
} // end extern "C"

View File

@ -20,10 +20,11 @@ namespace llvm {
// Ripped from lib/Target/TargetMachineC.cpp.
inline TargetMachine *unwrap(LLVMTargetMachineRef P) {
return reinterpret_cast<TargetMachine *>(P);
return reinterpret_cast<TargetMachine *>(P);
}
inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
return reinterpret_cast<LLVMTargetMachineRef>(const_cast<TargetMachine *>(P));
return reinterpret_cast<LLVMTargetMachineRef>(
const_cast<TargetMachine *>(P));
}
// unwrap for LLVMObjectFileRef
@ -31,7 +32,7 @@ inline LLVMTargetMachineRef wrap(const TargetMachine *P) {
namespace object {
inline OwningBinary<ObjectFile> *unwrap(LLVMObjectFileRef OF) {
return reinterpret_cast<OwningBinary<ObjectFile> *>(OF);
return reinterpret_cast<OwningBinary<ObjectFile> *>(OF);
}
} // namespace object
} // namespace llvm
@ -43,127 +44,127 @@ LLVMPY_LinkInMCJIT() { LLVMLinkInMCJIT(); }
API_EXPORT(void)
LLVMPY_DisposeExecutionEngine(LLVMExecutionEngineRef EE) {
LLVMDisposeExecutionEngine(EE);
LLVMDisposeExecutionEngine(EE);
}
API_EXPORT(void)
LLVMPY_AddModule(LLVMExecutionEngineRef EE, LLVMModuleRef M) {
LLVMAddModule(EE, M);
LLVMAddModule(EE, M);
}
API_EXPORT(int)
LLVMPY_RemoveModule(LLVMExecutionEngineRef EE, LLVMModuleRef M,
char **OutError) {
return LLVMRemoveModule(EE, M, &M, OutError);
return LLVMRemoveModule(EE, M, &M, OutError);
}
API_EXPORT(void)
LLVMPY_FinalizeObject(LLVMExecutionEngineRef EE) {
llvm::unwrap(EE)->finalizeObject();
llvm::unwrap(EE)->finalizeObject();
}
static LLVMExecutionEngineRef create_execution_engine(LLVMModuleRef M,
LLVMTargetMachineRef TM,
const char **OutError) {
LLVMExecutionEngineRef ee = nullptr;
LLVMExecutionEngineRef ee = nullptr;
llvm::EngineBuilder eb(std::unique_ptr<llvm::Module>(llvm::unwrap(M)));
std::string err;
eb.setErrorStr(&err);
eb.setEngineKind(llvm::EngineKind::JIT);
llvm::EngineBuilder eb(std::unique_ptr<llvm::Module>(llvm::unwrap(M)));
std::string err;
eb.setErrorStr(&err);
eb.setEngineKind(llvm::EngineKind::JIT);
/* EngineBuilder::create loads the current process symbols */
llvm::ExecutionEngine *engine = eb.create(llvm::unwrap(TM));
/* EngineBuilder::create loads the current process symbols */
llvm::ExecutionEngine *engine = eb.create(llvm::unwrap(TM));
if (!engine)
*OutError = LLVMPY_CreateString(err.c_str());
else
ee = llvm::wrap(engine);
return ee;
if (!engine)
*OutError = LLVMPY_CreateString(err.c_str());
else
ee = llvm::wrap(engine);
return ee;
}
API_EXPORT(LLVMExecutionEngineRef)
LLVMPY_CreateMCJITCompiler(LLVMModuleRef M, LLVMTargetMachineRef TM,
const char **OutError) {
return create_execution_engine(M, TM, OutError);
return create_execution_engine(M, TM, OutError);
}
API_EXPORT(uint64_t)
LLVMPY_GetGlobalValueAddress(LLVMExecutionEngineRef EE, const char *Name) {
return LLVMGetGlobalValueAddress(EE, Name);
return LLVMGetGlobalValueAddress(EE, Name);
}
API_EXPORT(uint64_t)
LLVMPY_GetFunctionAddress(LLVMExecutionEngineRef EE, const char *Name) {
return LLVMGetFunctionAddress(EE, Name);
return LLVMGetFunctionAddress(EE, Name);
}
API_EXPORT(void)
LLVMPY_RunStaticConstructors(LLVMExecutionEngineRef EE) {
return LLVMRunStaticConstructors(EE);
return LLVMRunStaticConstructors(EE);
}
API_EXPORT(void)
LLVMPY_RunStaticDestructors(LLVMExecutionEngineRef EE) {
return LLVMRunStaticDestructors(EE);
return LLVMRunStaticDestructors(EE);
}
API_EXPORT(void)
LLVMPY_AddGlobalMapping(LLVMExecutionEngineRef EE, LLVMValueRef Global,
void *Addr) {
LLVMAddGlobalMapping(EE, Global, Addr);
LLVMAddGlobalMapping(EE, Global, Addr);
}
API_EXPORT(LLVMTargetDataRef)
LLVMPY_GetExecutionEngineTargetData(LLVMExecutionEngineRef EE) {
return LLVMGetExecutionEngineTargetData(EE);
return LLVMGetExecutionEngineTargetData(EE);
}
API_EXPORT(int)
LLVMPY_TryAllocateExecutableMemory(void) {
using namespace llvm::sys;
std::error_code ec;
MemoryBlock mb = Memory::allocateMappedMemory(
4096, nullptr, Memory::MF_READ | Memory::MF_WRITE, ec);
if (!ec) {
ec = Memory::protectMappedMemory(mb, Memory::MF_READ | Memory::MF_EXEC);
(void)Memory::releaseMappedMemory(mb); /* Should always succeed */
}
return ec.value();
using namespace llvm::sys;
std::error_code ec;
MemoryBlock mb = Memory::allocateMappedMemory(
4096, nullptr, Memory::MF_READ | Memory::MF_WRITE, ec);
if (!ec) {
ec = Memory::protectMappedMemory(mb, Memory::MF_READ | Memory::MF_EXEC);
(void)Memory::releaseMappedMemory(mb); /* Should always succeed */
}
return ec.value();
}
API_EXPORT(bool)
LLVMPY_EnableJITEvents(LLVMExecutionEngineRef EE) {
llvm::JITEventListener *listener;
bool result = false;
llvm::JITEventListener *listener;
bool result = false;
#ifdef __linux__
listener = llvm::JITEventListener::createOProfileJITEventListener();
// if listener is null, then LLVM was not compiled for OProfile JIT events.
if (listener) {
llvm::unwrap(EE)->RegisterJITEventListener(listener);
result = true;
}
listener = llvm::JITEventListener::createOProfileJITEventListener();
// if listener is null, then LLVM was not compiled for OProfile JIT events.
if (listener) {
llvm::unwrap(EE)->RegisterJITEventListener(listener);
result = true;
}
#endif
listener = llvm::JITEventListener::createIntelJITEventListener();
// if listener is null, then LLVM was not compiled for Intel JIT events.
if (listener) {
llvm::unwrap(EE)->RegisterJITEventListener(listener);
result = true;
}
return result;
listener = llvm::JITEventListener::createIntelJITEventListener();
// if listener is null, then LLVM was not compiled for Intel JIT events.
if (listener) {
llvm::unwrap(EE)->RegisterJITEventListener(listener);
result = true;
}
return result;
}
API_EXPORT(void)
LLVMPY_MCJITAddObjectFile(LLVMExecutionEngineRef EE, LLVMObjectFileRef ObjF) {
using namespace llvm;
using namespace llvm::object;
auto engine = unwrap(EE);
auto object_file = unwrap(ObjF);
auto binary_tuple = object_file->takeBinary();
using namespace llvm;
using namespace llvm::object;
auto engine = unwrap(EE);
auto object_file = unwrap(ObjF);
auto binary_tuple = object_file->takeBinary();
engine->addObjectFile(
{std::move(binary_tuple.first), std::move(binary_tuple.second)});
engine->addObjectFile(
{std::move(binary_tuple.first), std::move(binary_tuple.second)});
}
//
@ -171,55 +172,56 @@ LLVMPY_MCJITAddObjectFile(LLVMExecutionEngineRef EE, LLVMObjectFileRef ObjF) {
//
typedef struct {
LLVMModuleRef modref;
const char *buf_ptr;
size_t buf_len;
LLVMModuleRef modref;
const char *buf_ptr;
size_t buf_len;
} ObjectCacheData;
typedef void (*ObjectCacheNotifyFunc)(void *, const ObjectCacheData *);
typedef void (*ObjectCacheGetObjectFunc)(void *, ObjectCacheData *);
class LLVMPYObjectCache : public llvm::ObjectCache {
public:
LLVMPYObjectCache(ObjectCacheNotifyFunc notify_func,
ObjectCacheGetObjectFunc getobject_func, void *user_data)
: notify_func(notify_func), getobject_func(getobject_func),
user_data(user_data) {}
public:
LLVMPYObjectCache(ObjectCacheNotifyFunc notify_func,
ObjectCacheGetObjectFunc getobject_func, void *user_data)
: notify_func(notify_func), getobject_func(getobject_func),
user_data(user_data) {}
virtual void notifyObjectCompiled(const llvm::Module *M,
llvm::MemoryBufferRef MBR) {
if (notify_func) {
ObjectCacheData data = {llvm::wrap(M), MBR.getBufferStart(),
MBR.getBufferSize()};
notify_func(user_data, &data);
virtual void notifyObjectCompiled(const llvm::Module *M,
llvm::MemoryBufferRef MBR) {
if (notify_func) {
ObjectCacheData data = {llvm::wrap(M), MBR.getBufferStart(),
MBR.getBufferSize()};
notify_func(user_data, &data);
}
}
}
// MCJIT will call this function before compiling any module
// MCJIT takes ownership of both the MemoryBuffer object and the memory
// to which it refers.
virtual std::unique_ptr<llvm::MemoryBuffer> getObject(const llvm::Module *M) {
std::unique_ptr<llvm::MemoryBuffer> res = nullptr;
// MCJIT will call this function before compiling any module
// MCJIT takes ownership of both the MemoryBuffer object and the memory
// to which it refers.
virtual std::unique_ptr<llvm::MemoryBuffer>
getObject(const llvm::Module *M) {
std::unique_ptr<llvm::MemoryBuffer> res = nullptr;
if (getobject_func) {
ObjectCacheData data = {llvm::wrap(M), nullptr, 0};
if (getobject_func) {
ObjectCacheData data = {llvm::wrap(M), nullptr, 0};
getobject_func(user_data, &data);
if (data.buf_ptr && data.buf_len > 0) {
// Assume the returned string was allocated
// with LLVMPY_CreateByteString
res = llvm::MemoryBuffer::getMemBufferCopy(
llvm::StringRef(data.buf_ptr, data.buf_len));
LLVMPY_DisposeString(data.buf_ptr);
}
getobject_func(user_data, &data);
if (data.buf_ptr && data.buf_len > 0) {
// Assume the returned string was allocated
// with LLVMPY_CreateByteString
res = llvm::MemoryBuffer::getMemBufferCopy(
llvm::StringRef(data.buf_ptr, data.buf_len));
LLVMPY_DisposeString(data.buf_ptr);
}
}
return res;
}
return res;
}
private:
ObjectCacheNotifyFunc notify_func;
ObjectCacheGetObjectFunc getobject_func;
void *user_data;
private:
ObjectCacheNotifyFunc notify_func;
ObjectCacheGetObjectFunc getobject_func;
void *user_data;
};
typedef LLVMPYObjectCache *LLVMPYObjectCacheRef;
@ -228,7 +230,7 @@ API_EXPORT(LLVMPYObjectCacheRef)
LLVMPY_CreateObjectCache(ObjectCacheNotifyFunc notify_func,
ObjectCacheGetObjectFunc getobject_func,
void *user_data) {
return new LLVMPYObjectCache(notify_func, getobject_func, user_data);
return new LLVMPYObjectCache(notify_func, getobject_func, user_data);
}
API_EXPORT(void)
@ -236,7 +238,7 @@ LLVMPY_DisposeObjectCache(LLVMPYObjectCacheRef C) { delete C; }
API_EXPORT(void)
LLVMPY_SetObjectCache(LLVMExecutionEngineRef EE, LLVMPYObjectCacheRef C) {
llvm::unwrap(EE)->setObjectCache(C);
llvm::unwrap(EE)->setObjectCache(C);
}
} // end extern "C"

View File

@ -8,9 +8,9 @@
extern "C" {
#define INIT(F) \
API_EXPORT(void) LLVMPY_Initialize##F() { \
LLVMInitialize##F(LLVMGetGlobalPassRegistry()); \
}
API_EXPORT(void) LLVMPY_Initialize##F() { \
LLVMInitialize##F(LLVMGetGlobalPassRegistry()); \
}
INIT(Core)
INIT(TransformUtils)
@ -32,7 +32,7 @@ LLVMPY_Shutdown() { LLVMShutdown(); }
// Target Initialization
#define INIT(F) \
API_EXPORT(void) LLVMPY_Initialize##F() { LLVMInitialize##F(); }
API_EXPORT(void) LLVMPY_Initialize##F() { LLVMInitialize##F(); }
// NOTE: it is important that we don't export functions which we don't use,
// especially those which may pull in large amounts of additional code or data.
@ -50,14 +50,14 @@ INIT(NativeAsmPrinter)
API_EXPORT(unsigned int)
LLVMPY_GetVersionInfo() {
unsigned int verinfo = 0;
verinfo += LLVM_VERSION_MAJOR << 16;
verinfo += LLVM_VERSION_MINOR << 8;
unsigned int verinfo = 0;
verinfo += LLVM_VERSION_MAJOR << 16;
verinfo += LLVM_VERSION_MINOR << 8;
#ifdef LLVM_VERSION_PATCH
/* Not available under Windows... */
verinfo += LLVM_VERSION_PATCH << 0;
/* Not available under Windows... */
verinfo += LLVM_VERSION_PATCH << 0;
#endif
return verinfo;
return verinfo;
}
} // end extern "C"

View File

@ -11,50 +11,50 @@ extern "C" {
API_EXPORT(int)
LLVMPY_LinkModules(LLVMModuleRef Dest, LLVMModuleRef Src, const char **Err) {
using namespace llvm;
std::string errorstring;
llvm::raw_string_ostream errstream(errorstring);
Module *D = unwrap(Dest);
LLVMContext &Ctx = D->getContext();
using namespace llvm;
std::string errorstring;
llvm::raw_string_ostream errstream(errorstring);
Module *D = unwrap(Dest);
LLVMContext &Ctx = D->getContext();
// This exists at the change to LLVM 6.x
// Link error diagnostics end up with a call to abort()
// install this handler to instead extract the reason for failure
// and report it.
class ReportNotAbortDiagnosticHandler : public DiagnosticHandler {
public:
ReportNotAbortDiagnosticHandler(llvm::raw_string_ostream &s)
: raw_stream(s) {}
// This exists at the change to LLVM 6.x
// Link error diagnostics end up with a call to abort()
// install this handler to instead extract the reason for failure
// and report it.
class ReportNotAbortDiagnosticHandler : public DiagnosticHandler {
public:
ReportNotAbortDiagnosticHandler(llvm::raw_string_ostream &s)
: raw_stream(s) {}
bool handleDiagnostics(const DiagnosticInfo &DI) override {
llvm::DiagnosticPrinterRawOStream DP(raw_stream);
DI.print(DP);
return true;
bool handleDiagnostics(const DiagnosticInfo &DI) override {
llvm::DiagnosticPrinterRawOStream DP(raw_stream);
DI.print(DP);
return true;
}
private:
llvm::raw_string_ostream &raw_stream;
};
// save current handler as "old"
auto OldDiagnosticHandler = Ctx.getDiagnosticHandler();
Ctx.setDiagnosticHandler(
std::make_unique<ReportNotAbortDiagnosticHandler>(errstream));
// link
bool failed = LLVMLinkModules2(Dest, Src);
// put old handler back
Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
// if linking failed extract the reason for the failure
if (failed) {
errstream.flush();
*Err = LLVMPY_CreateString(errorstring.c_str());
}
private:
llvm::raw_string_ostream &raw_stream;
};
// save current handler as "old"
auto OldDiagnosticHandler = Ctx.getDiagnosticHandler();
Ctx.setDiagnosticHandler(
std::make_unique<ReportNotAbortDiagnosticHandler>(errstream));
// link
bool failed = LLVMLinkModules2(Dest, Src);
// put old handler back
Ctx.setDiagnosticHandler(std::move(OldDiagnosticHandler));
// if linking failed extract the reason for the failure
if (failed) {
errstream.flush();
*Err = LLVMPY_CreateString(errorstring.c_str());
}
return failed;
return failed;
}
} // end extern "C"

View File

@ -8,11 +8,11 @@
/* An iterator around a module's globals, including the stop condition */
struct GlobalsIterator {
typedef llvm::Module::global_iterator iterator;
iterator cur;
iterator end;
typedef llvm::Module::global_iterator iterator;
iterator cur;
iterator end;
GlobalsIterator(iterator cur, iterator end) : cur(cur), end(end) {}
GlobalsIterator(iterator cur, iterator end) : cur(cur), end(end) {}
};
struct OpaqueGlobalsIterator;
@ -20,12 +20,12 @@ typedef OpaqueGlobalsIterator *LLVMGlobalsIteratorRef;
/* An iterator around a module's functions, including the stop condition */
struct FunctionsIterator {
typedef llvm::Module::const_iterator const_iterator;
const_iterator cur;
const_iterator end;
typedef llvm::Module::const_iterator const_iterator;
const_iterator cur;
const_iterator end;
FunctionsIterator(const_iterator cur, const_iterator end)
: cur(cur), end(end) {}
FunctionsIterator(const_iterator cur, const_iterator end)
: cur(cur), end(end) {}
};
struct OpaqueFunctionsIterator;
@ -33,22 +33,23 @@ typedef OpaqueFunctionsIterator *LLVMFunctionsIteratorRef;
/* module types iterator */
class TypesIterator {
private:
llvm::TypeFinder finder;
using const_iterator = llvm::TypeFinder::const_iterator;
const_iterator cur;
private:
llvm::TypeFinder finder;
using const_iterator = llvm::TypeFinder::const_iterator;
const_iterator cur;
public:
TypesIterator(llvm::Module &m, bool namedOnly) : finder(llvm::TypeFinder()) {
finder.run(m, namedOnly);
cur = finder.begin();
}
const llvm::Type *next() {
if (cur != finder.end()) {
return *cur++;
public:
TypesIterator(llvm::Module &m, bool namedOnly)
: finder(llvm::TypeFinder()) {
finder.run(m, namedOnly);
cur = finder.begin();
}
const llvm::Type *next() {
if (cur != finder.end()) {
return *cur++;
}
return nullptr;
}
return nullptr;
}
};
typedef TypesIterator *LLVMTypesIteratorRef;
@ -60,27 +61,27 @@ typedef TypesIterator *LLVMTypesIteratorRef;
namespace llvm {
static LLVMGlobalsIteratorRef wrap(GlobalsIterator *GI) {
return reinterpret_cast<LLVMGlobalsIteratorRef>(GI);
return reinterpret_cast<LLVMGlobalsIteratorRef>(GI);
}
static GlobalsIterator *unwrap(LLVMGlobalsIteratorRef GI) {
return reinterpret_cast<GlobalsIterator *>(GI);
return reinterpret_cast<GlobalsIterator *>(GI);
}
static LLVMFunctionsIteratorRef wrap(FunctionsIterator *GI) {
return reinterpret_cast<LLVMFunctionsIteratorRef>(GI);
return reinterpret_cast<LLVMFunctionsIteratorRef>(GI);
}
static FunctionsIterator *unwrap(LLVMFunctionsIteratorRef GI) {
return reinterpret_cast<FunctionsIterator *>(GI);
return reinterpret_cast<FunctionsIterator *>(GI);
}
static LLVMTypesIteratorRef wrap(TypesIterator *TyI) {
return reinterpret_cast<LLVMTypesIteratorRef>(TyI);
return reinterpret_cast<LLVMTypesIteratorRef>(TyI);
}
static TypesIterator *unwrap(LLVMTypesIteratorRef TyI) {
return reinterpret_cast<TypesIterator *>(TyI);
return reinterpret_cast<TypesIterator *>(TyI);
}
} // end namespace llvm
@ -96,95 +97,95 @@ LLVMPY_DisposeModule(LLVMModuleRef m) { return LLVMDisposeModule(m); }
API_EXPORT(void)
LLVMPY_PrintModuleToString(LLVMModuleRef M, const char **outstr) {
// Change the locale to en_US before calling LLVM to print the module
// due to a LLVM bug https://llvm.org/bugs/show_bug.cgi?id=12906
char *old_locale = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
// Change the locale to en_US before calling LLVM to print the module
// due to a LLVM bug https://llvm.org/bugs/show_bug.cgi?id=12906
char *old_locale = strdup(setlocale(LC_ALL, NULL));
setlocale(LC_ALL, "C");
*outstr = LLVMPrintModuleToString(M);
*outstr = LLVMPrintModuleToString(M);
// Revert locale
setlocale(LC_ALL, old_locale);
free(old_locale);
// Revert locale
setlocale(LC_ALL, old_locale);
free(old_locale);
}
API_EXPORT(const char *)
LLVMPY_GetModuleSourceFileName(LLVMModuleRef M) {
return llvm::unwrap(M)->getSourceFileName().c_str();
return llvm::unwrap(M)->getSourceFileName().c_str();
}
API_EXPORT(const char *)
LLVMPY_GetModuleName(LLVMModuleRef M) {
return llvm::unwrap(M)->getModuleIdentifier().c_str();
return llvm::unwrap(M)->getModuleIdentifier().c_str();
}
API_EXPORT(void)
LLVMPY_SetModuleName(LLVMModuleRef M, const char *Name) {
llvm::unwrap(M)->setModuleIdentifier(Name);
llvm::unwrap(M)->setModuleIdentifier(Name);
}
API_EXPORT(LLVMValueRef)
LLVMPY_GetNamedFunction(LLVMModuleRef M, const char *Name) {
return LLVMGetNamedFunction(M, Name);
return LLVMGetNamedFunction(M, Name);
}
API_EXPORT(LLVMValueRef)
LLVMPY_GetNamedGlobalVariable(LLVMModuleRef M, const char *Name) {
using namespace llvm;
return wrap(unwrap(M)->getGlobalVariable(Name));
using namespace llvm;
return wrap(unwrap(M)->getGlobalVariable(Name));
}
API_EXPORT(LLVMTypeRef)
LLVMPY_GetNamedStructType(LLVMModuleRef M, const char *Name) {
return LLVMGetTypeByName(M, Name);
return LLVMGetTypeByName(M, Name);
}
API_EXPORT(int)
LLVMPY_VerifyModule(LLVMModuleRef M, char **OutMsg) {
return LLVMVerifyModule(M, LLVMReturnStatusAction, OutMsg);
return LLVMVerifyModule(M, LLVMReturnStatusAction, OutMsg);
}
API_EXPORT(void)
LLVMPY_GetDataLayout(LLVMModuleRef M, const char **DL) {
*DL = LLVMGetDataLayoutStr(M);
*DL = LLVMGetDataLayoutStr(M);
}
API_EXPORT(void)
LLVMPY_SetDataLayout(LLVMModuleRef M, const char *DL) {
LLVMSetDataLayout(M, DL);
LLVMSetDataLayout(M, DL);
}
API_EXPORT(void)
LLVMPY_GetTarget(LLVMModuleRef M, const char **Triple) {
*Triple = LLVMGetTarget(M);
*Triple = LLVMGetTarget(M);
}
API_EXPORT(void)
LLVMPY_SetTarget(LLVMModuleRef M, const char *Triple) {
LLVMSetTarget(M, Triple);
LLVMSetTarget(M, Triple);
}
// Iteration APIs
API_EXPORT(LLVMGlobalsIteratorRef)
LLVMPY_ModuleGlobalsIter(LLVMModuleRef M) {
using namespace llvm;
Module *mod = unwrap(M);
return wrap(new GlobalsIterator(mod->global_begin(), mod->global_end()));
using namespace llvm;
Module *mod = unwrap(M);
return wrap(new GlobalsIterator(mod->global_begin(), mod->global_end()));
}
API_EXPORT(LLVMFunctionsIteratorRef)
LLVMPY_ModuleFunctionsIter(LLVMModuleRef M) {
using namespace llvm;
Module *mod = unwrap(M);
return wrap(new FunctionsIterator(mod->begin(), mod->end()));
using namespace llvm;
Module *mod = unwrap(M);
return wrap(new FunctionsIterator(mod->begin(), mod->end()));
}
API_EXPORT(LLVMTypesIteratorRef)
LLVMPY_ModuleTypesIter(LLVMModuleRef M) {
llvm::Module *mod = llvm::unwrap(M);
auto *iter = new TypesIterator(*mod, false);
return llvm::wrap(iter);
llvm::Module *mod = llvm::unwrap(M);
auto *iter = new TypesIterator(*mod, false);
return llvm::wrap(iter);
}
/*
@ -192,39 +193,39 @@ LLVMPY_ModuleTypesIter(LLVMModuleRef M) {
*/
API_EXPORT(LLVMValueRef)
LLVMPY_GlobalsIterNext(LLVMGlobalsIteratorRef GI) {
using namespace llvm;
GlobalsIterator *iter = unwrap(GI);
if (iter->cur != iter->end) {
return wrap(&*iter->cur++);
} else {
return NULL;
}
using namespace llvm;
GlobalsIterator *iter = unwrap(GI);
if (iter->cur != iter->end) {
return wrap(&*iter->cur++);
} else {
return NULL;
}
}
API_EXPORT(LLVMValueRef)
LLVMPY_FunctionsIterNext(LLVMFunctionsIteratorRef GI) {
using namespace llvm;
FunctionsIterator *iter = unwrap(GI);
if (iter->cur != iter->end) {
return wrap(&*iter->cur++);
} else {
return NULL;
}
using namespace llvm;
FunctionsIterator *iter = unwrap(GI);
if (iter->cur != iter->end) {
return wrap(&*iter->cur++);
} else {
return NULL;
}
}
API_EXPORT(LLVMTypeRef)
LLVMPY_TypesIterNext(LLVMTypesIteratorRef TyI) {
return llvm::wrap(llvm::unwrap(TyI)->next());
return llvm::wrap(llvm::unwrap(TyI)->next());
}
API_EXPORT(void)
LLVMPY_DisposeGlobalsIter(LLVMGlobalsIteratorRef GI) {
delete llvm::unwrap(GI);
delete llvm::unwrap(GI);
}
API_EXPORT(void)
LLVMPY_DisposeFunctionsIter(LLVMFunctionsIteratorRef GI) {
delete llvm::unwrap(GI);
delete llvm::unwrap(GI);
}
API_EXPORT(void)

View File

@ -10,12 +10,12 @@
// From lib/Object/Object.cpp
namespace llvm {
inline object::section_iterator *unwrap(LLVMSectionIteratorRef SI) {
return reinterpret_cast<object::section_iterator *>(SI);
return reinterpret_cast<object::section_iterator *>(SI);
}
inline LLVMSectionIteratorRef wrap(const object::section_iterator *SI) {
return reinterpret_cast<LLVMSectionIteratorRef>(
const_cast<object::section_iterator *>(SI));
return reinterpret_cast<LLVMSectionIteratorRef>(
const_cast<object::section_iterator *>(SI));
}
} // namespace llvm
@ -23,13 +23,13 @@ extern "C" {
API_EXPORT(LLVMObjectFileRef)
LLVMPY_CreateObjectFile(const char *buf, const size_t n) {
return LLVMCreateObjectFile(
LLVMCreateMemoryBufferWithMemoryRangeCopy(buf, n, ""));
return LLVMCreateObjectFile(
LLVMCreateMemoryBufferWithMemoryRangeCopy(buf, n, ""));
}
API_EXPORT(void)
LLVMPY_DisposeObjectFile(LLVMObjectFileRef O) {
return LLVMDisposeObjectFile(O);
return LLVMDisposeObjectFile(O);
}
API_EXPORT(LLVMSectionIteratorRef)
@ -37,42 +37,42 @@ LLVMPY_GetSections(LLVMObjectFileRef O) { return LLVMGetSections(O); }
API_EXPORT(void)
LLVMPY_DisposeSectionIterator(LLVMSectionIteratorRef SI) {
LLVMDisposeSectionIterator(SI);
LLVMDisposeSectionIterator(SI);
}
API_EXPORT(void)
LLVMPY_MoveToNextSection(LLVMSectionIteratorRef SI) {
LLVMMoveToNextSection(SI);
LLVMMoveToNextSection(SI);
}
API_EXPORT(bool)
LLVMPY_IsSectionIteratorAtEnd(LLVMObjectFileRef O, LLVMSectionIteratorRef SI) {
return LLVMIsSectionIteratorAtEnd(O, SI);
return LLVMIsSectionIteratorAtEnd(O, SI);
}
API_EXPORT(const char *)
LLVMPY_GetSectionName(LLVMSectionIteratorRef SI) {
return LLVMGetSectionName(SI);
return LLVMGetSectionName(SI);
}
API_EXPORT(uint64_t)
LLVMPY_GetSectionAddress(LLVMSectionIteratorRef SI) {
return LLVMGetSectionAddress(SI);
return LLVMGetSectionAddress(SI);
}
API_EXPORT(const char *)
LLVMPY_GetSectionContents(LLVMSectionIteratorRef SI) {
return LLVMGetSectionContents(SI);
return LLVMGetSectionContents(SI);
}
API_EXPORT(uint64_t)
LLVMPY_GetSectionSize(LLVMSectionIteratorRef SI) {
return LLVMGetSectionSize(SI);
return LLVMGetSectionSize(SI);
}
API_EXPORT(bool)
LLVMPY_IsSectionText(LLVMSectionIteratorRef SI) {
return (*llvm::unwrap(SI))->isText();
return (*llvm::unwrap(SI))->isText();
}
} // end extern C

View File

@ -28,11 +28,11 @@ LLVMPY_SetTimePasses(bool enable) { TimePassesIsEnabled = enable; }
API_EXPORT(void)
LLVMPY_ReportAndResetTimings(const char **outmsg) {
std::string osbuf;
raw_string_ostream os(osbuf);
reportAndResetTimings(&os);
os.flush();
*outmsg = LLVMPY_CreateString(os.str().c_str());
std::string osbuf;
raw_string_ostream os(osbuf);
reportAndResetTimings(&os);
os.flush();
*outmsg = LLVMPY_CreateString(os.str().c_str());
}
API_EXPORT(LLVMPassManagerRef)
@ -40,57 +40,57 @@ LLVMPY_CreatePassManager() { return LLVMCreatePassManager(); }
API_EXPORT(void)
LLVMPY_DisposePassManager(LLVMPassManagerRef PM) {
return LLVMDisposePassManager(PM);
return LLVMDisposePassManager(PM);
}
API_EXPORT(LLVMPassManagerRef)
LLVMPY_CreateFunctionPassManager(LLVMModuleRef M) {
return LLVMCreateFunctionPassManagerForModule(M);
return LLVMCreateFunctionPassManagerForModule(M);
}
API_EXPORT(int)
LLVMPY_RunPassManager(LLVMPassManagerRef PM, LLVMModuleRef M) {
return LLVMRunPassManager(PM, M);
return LLVMRunPassManager(PM, M);
}
API_EXPORT(int)
LLVMPY_RunFunctionPassManager(LLVMPassManagerRef PM, LLVMValueRef F) {
return LLVMRunFunctionPassManager(PM, F);
return LLVMRunFunctionPassManager(PM, F);
}
API_EXPORT(int)
LLVMPY_InitializeFunctionPassManager(LLVMPassManagerRef FPM) {
return LLVMInitializeFunctionPassManager(FPM);
return LLVMInitializeFunctionPassManager(FPM);
}
API_EXPORT(int)
LLVMPY_FinalizeFunctionPassManager(LLVMPassManagerRef FPM) {
return LLVMFinalizeFunctionPassManager(FPM);
return LLVMFinalizeFunctionPassManager(FPM);
}
API_EXPORT(void)
LLVMPY_AddConstantMergePass(LLVMPassManagerRef PM) {
LLVMAddConstantMergePass(PM);
LLVMAddConstantMergePass(PM);
}
API_EXPORT(void)
LLVMPY_AddDeadArgEliminationPass(LLVMPassManagerRef PM) {
LLVMAddDeadArgEliminationPass(PM);
LLVMAddDeadArgEliminationPass(PM);
}
API_EXPORT(void)
LLVMPY_AddFunctionAttrsPass(LLVMPassManagerRef PM) {
LLVMAddFunctionAttrsPass(PM);
LLVMAddFunctionAttrsPass(PM);
}
API_EXPORT(void)
LLVMPY_AddFunctionInliningPass(LLVMPassManagerRef PM, int Threshold) {
unwrap(PM)->add(createFunctionInliningPass(Threshold));
unwrap(PM)->add(createFunctionInliningPass(Threshold));
}
API_EXPORT(void)
LLVMPY_AddGlobalOptimizerPass(LLVMPassManagerRef PM) {
LLVMAddGlobalOptimizerPass(PM);
LLVMAddGlobalOptimizerPass(PM);
}
API_EXPORT(void)
@ -101,12 +101,12 @@ LLVMPY_AddIPSCCPPass(LLVMPassManagerRef PM) { LLVMAddIPSCCPPass(PM); }
API_EXPORT(void)
LLVMPY_AddDeadCodeEliminationPass(LLVMPassManagerRef PM) {
unwrap(PM)->add(createDeadCodeEliminationPass());
unwrap(PM)->add(createDeadCodeEliminationPass());
}
API_EXPORT(void)
LLVMPY_AddCFGSimplificationPass(LLVMPassManagerRef PM) {
LLVMAddCFGSimplificationPass(PM);
LLVMAddCFGSimplificationPass(PM);
}
API_EXPORT(void)
@ -114,7 +114,7 @@ LLVMPY_AddGVNPass(LLVMPassManagerRef PM) { LLVMAddGVNPass(PM); }
API_EXPORT(void)
LLVMPY_AddInstructionCombiningPass(LLVMPassManagerRef PM) {
LLVMAddInstructionCombiningPass(PM);
LLVMAddInstructionCombiningPass(PM);
}
API_EXPORT(void)
@ -128,17 +128,17 @@ LLVMPY_AddSROAPass(LLVMPassManagerRef PM) { unwrap(PM)->add(createSROAPass()); }
API_EXPORT(void)
LLVMPY_AddTypeBasedAliasAnalysisPass(LLVMPassManagerRef PM) {
LLVMAddTypeBasedAliasAnalysisPass(PM);
LLVMAddTypeBasedAliasAnalysisPass(PM);
}
API_EXPORT(void)
LLVMPY_AddBasicAliasAnalysisPass(LLVMPassManagerRef PM) {
LLVMAddBasicAliasAnalysisPass(PM);
LLVMAddBasicAliasAnalysisPass(PM);
}
API_EXPORT(void)
LLVMPY_LLVMAddLoopRotatePass(LLVMPassManagerRef PM) {
LLVMAddLoopRotatePass(PM);
LLVMAddLoopRotatePass(PM);
}
} // end extern "C"

View File

@ -16,21 +16,21 @@
namespace llvm {
inline LLVMTargetLibraryInfoRef wrap(TargetLibraryInfo *TLI) {
return reinterpret_cast<LLVMTargetLibraryInfoRef>(TLI);
return reinterpret_cast<LLVMTargetLibraryInfoRef>(TLI);
}
inline TargetLibraryInfo *unwrap(LLVMTargetLibraryInfoRef TLI) {
return reinterpret_cast<TargetLibraryInfo *>(TLI);
return reinterpret_cast<TargetLibraryInfo *>(TLI);
}
inline Target *unwrap(LLVMTargetRef T) { return reinterpret_cast<Target *>(T); }
inline TargetMachine *unwrap(LLVMTargetMachineRef TM) {
return reinterpret_cast<TargetMachine *>(TM);
return reinterpret_cast<TargetMachine *>(TM);
}
inline LLVMTargetMachineRef wrap(TargetMachine *TM) {
return reinterpret_cast<LLVMTargetMachineRef>(TM);
return reinterpret_cast<LLVMTargetMachineRef>(TM);
}
} // namespace llvm
@ -39,7 +39,7 @@ extern "C" {
API_EXPORT(void)
LLVMPY_GetProcessTriple(const char **Out) {
*Out = LLVMPY_CreateString(llvm::sys::getProcessTriple().c_str());
*Out = LLVMPY_CreateString(llvm::sys::getProcessTriple().c_str());
}
/**
@ -49,39 +49,39 @@ LLVMPY_GetProcessTriple(const char **Out) {
*/
API_EXPORT(int)
LLVMPY_GetHostCPUFeatures(const char **Out) {
llvm::StringMap<bool> features;
std::ostringstream buf;
if (llvm::sys::getHostCPUFeatures(features)) {
for (auto &F : features) {
if (buf.tellp()) {
buf << ',';
}
buf << ((F.second ? "+" : "-") + F.first()).str();
llvm::StringMap<bool> features;
std::ostringstream buf;
if (llvm::sys::getHostCPUFeatures(features)) {
for (auto &F : features) {
if (buf.tellp()) {
buf << ',';
}
buf << ((F.second ? "+" : "-") + F.first()).str();
}
*Out = LLVMPY_CreateString(buf.str().c_str());
return 1;
}
*Out = LLVMPY_CreateString(buf.str().c_str());
return 1;
}
return 0;
return 0;
}
API_EXPORT(void)
LLVMPY_GetDefaultTargetTriple(const char **Out) {
*Out = LLVMPY_CreateString(llvm::sys::getDefaultTargetTriple().c_str());
*Out = LLVMPY_CreateString(llvm::sys::getDefaultTargetTriple().c_str());
}
API_EXPORT(void)
LLVMPY_GetHostCPUName(const char **Out) {
*Out = LLVMPY_CreateString(llvm::sys::getHostCPUName().data());
*Out = LLVMPY_CreateString(llvm::sys::getHostCPUName().data());
}
API_EXPORT(int)
LLVMPY_GetTripleObjectFormat(const char *tripleStr) {
return llvm::Triple(tripleStr).getObjectFormat();
return llvm::Triple(tripleStr).getObjectFormat();
}
API_EXPORT(LLVMTargetDataRef)
LLVMPY_CreateTargetData(const char *StringRep) {
return LLVMCreateTargetData(StringRep);
return LLVMCreateTargetData(StringRep);
}
//// Nothing is creating a TargetLibraryInfo
@ -94,7 +94,7 @@ LLVMPY_CreateTargetData(const char *StringRep) {
API_EXPORT(void)
LLVMPY_CopyStringRepOfTargetData(LLVMTargetDataRef TD, char **Out) {
*Out = LLVMCopyStringRepOfTargetData(TD);
*Out = LLVMCopyStringRepOfTargetData(TD);
}
API_EXPORT(void)
@ -102,45 +102,45 @@ LLVMPY_DisposeTargetData(LLVMTargetDataRef TD) { LLVMDisposeTargetData(TD); }
API_EXPORT(long long)
LLVMPY_ABISizeOfType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
return (long long)LLVMABISizeOfType(TD, Ty);
return (long long)LLVMABISizeOfType(TD, Ty);
}
API_EXPORT(long long)
LLVMPY_OffsetOfElement(LLVMTargetDataRef TD, LLVMTypeRef Ty, int Element) {
llvm::Type *tp = llvm::unwrap(Ty);
if (!tp->isStructTy())
return -1;
return (long long)LLVMOffsetOfElement(TD, Ty, Element);
llvm::Type *tp = llvm::unwrap(Ty);
if (!tp->isStructTy())
return -1;
return (long long)LLVMOffsetOfElement(TD, Ty, Element);
}
API_EXPORT(long long)
LLVMPY_ABISizeOfElementType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
llvm::Type *tp = llvm::unwrap(Ty);
if (!tp->isPointerTy())
return -1;
tp = tp->getPointerElementType();
return (long long)LLVMABISizeOfType(TD, llvm::wrap(tp));
llvm::Type *tp = llvm::unwrap(Ty);
if (!tp->isPointerTy())
return -1;
tp = tp->getPointerElementType();
return (long long)LLVMABISizeOfType(TD, llvm::wrap(tp));
}
API_EXPORT(long long)
LLVMPY_ABIAlignmentOfElementType(LLVMTargetDataRef TD, LLVMTypeRef Ty) {
llvm::Type *tp = llvm::unwrap(Ty);
if (!tp->isPointerTy())
return -1;
tp = tp->getPointerElementType();
return (long long)LLVMABIAlignmentOfType(TD, llvm::wrap(tp));
llvm::Type *tp = llvm::unwrap(Ty);
if (!tp->isPointerTy())
return -1;
tp = tp->getPointerElementType();
return (long long)LLVMABIAlignmentOfType(TD, llvm::wrap(tp));
}
API_EXPORT(LLVMTargetRef)
LLVMPY_GetTargetFromTriple(const char *Triple, const char **ErrOut) {
char *ErrorMessage;
LLVMTargetRef T;
if (LLVMGetTargetFromTriple(Triple, &T, &ErrorMessage)) {
*ErrOut = LLVMPY_CreateString(ErrorMessage);
LLVMDisposeMessage(ErrorMessage);
return NULL;
}
return T;
char *ErrorMessage;
LLVMTargetRef T;
if (LLVMGetTargetFromTriple(Triple, &T, &ErrorMessage)) {
*ErrOut = LLVMPY_CreateString(ErrorMessage);
LLVMDisposeMessage(ErrorMessage);
return NULL;
}
return T;
}
API_EXPORT(const char *)
@ -148,7 +148,7 @@ LLVMPY_GetTargetName(LLVMTargetRef T) { return LLVMGetTargetName(T); }
API_EXPORT(const char *)
LLVMPY_GetTargetDescription(LLVMTargetRef T) {
return LLVMGetTargetDescription(T);
return LLVMGetTargetDescription(T);
}
API_EXPORT(LLVMTargetMachineRef)
@ -156,107 +156,108 @@ LLVMPY_CreateTargetMachine(LLVMTargetRef T, const char *Triple, const char *CPU,
const char *Features, int OptLevel,
const char *RelocModel, const char *CodeModel,
int PrintMC, int JIT, const char *ABIName) {
using namespace llvm;
CodeGenOpt::Level cgol;
switch (OptLevel) {
case 0:
cgol = CodeGenOpt::None;
break;
case 1:
cgol = CodeGenOpt::Less;
break;
case 3:
cgol = CodeGenOpt::Aggressive;
break;
case 2:
default:
cgol = CodeGenOpt::Default;
}
using namespace llvm;
CodeGenOpt::Level cgol;
switch (OptLevel) {
case 0:
cgol = CodeGenOpt::None;
break;
case 1:
cgol = CodeGenOpt::Less;
break;
case 3:
cgol = CodeGenOpt::Aggressive;
break;
case 2:
default:
cgol = CodeGenOpt::Default;
}
CodeModel::Model cm;
std::string cms(CodeModel);
if (cms == "small")
cm = CodeModel::Small;
else if (cms == "kernel")
cm = CodeModel::Kernel;
else if (cms == "medium")
cm = CodeModel::Medium;
else if (cms == "large")
cm = CodeModel::Large;
else if (cms == "default") // As per LLVM 5, needed for AOT
cm = CodeModel::Small;
else { // catches "jitdefault" and not set, as per LLVM 5, needed for MCJIT
// fall through, use model based on bitness
int bits = sizeof(void *);
if (bits == 4)
cm = CodeModel::Small;
else
cm = CodeModel::Large;
}
CodeModel::Model cm;
std::string cms(CodeModel);
if (cms == "small")
cm = CodeModel::Small;
else if (cms == "kernel")
cm = CodeModel::Kernel;
else if (cms == "medium")
cm = CodeModel::Medium;
else if (cms == "large")
cm = CodeModel::Large;
else if (cms == "default") // As per LLVM 5, needed for AOT
cm = CodeModel::Small;
else { // catches "jitdefault" and not set, as per LLVM 5, needed for MCJIT
// fall through, use model based on bitness
int bits = sizeof(void *);
if (bits == 4)
cm = CodeModel::Small;
else
cm = CodeModel::Large;
}
Optional<Reloc::Model> rm;
std::string rms(RelocModel);
if (rms == "static")
rm = Reloc::Static;
else if (rms == "pic")
rm = Reloc::PIC_;
else if (rms == "dynamicnopic")
rm = Reloc::DynamicNoPIC;
Optional<Reloc::Model> rm;
std::string rms(RelocModel);
if (rms == "static")
rm = Reloc::Static;
else if (rms == "pic")
rm = Reloc::PIC_;
else if (rms == "dynamicnopic")