Skip to content

Commit

Permalink
Build fixes for LLVM 18.
Browse files Browse the repository at this point in the history
  • Loading branch information
elliottslaughter committed Jun 19, 2024
1 parent 7705ffb commit 0321fba
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 3 deletions.
2 changes: 2 additions & 0 deletions src/llvmheaders.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@
#include "llvm/Support/Program.h"
#include "llvm/Transforms/Utils/Cloning.h"
#include "llvm/Transforms/IPO.h"
#if LLVM_VERSION < 180
#include "llvm/Transforms/Vectorize.h"
#endif
#if LLVM_VERSION < 170
#include "llvm/Transforms/IPO/PassManagerBuilder.h"
#else
Expand Down
29 changes: 26 additions & 3 deletions src/tcompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,12 @@ int terra_inittarget(lua_State *L) {
// GV tables
CodeModel::Small,
#endif
CodeGenOpt::Aggressive);
#if LLVM_VERSION < 180
CodeGenOpt::Aggressive
#else
CodeGenOptLevel::Aggressive
#endif
);
TT->external = new Module("external", *TT->ctx);
TT->external->setTargetTriple(TT->Triple);
lua_pushlightuserdata(L, TT);
Expand Down Expand Up @@ -404,7 +409,13 @@ static void InitializeJIT(TerraCompilationUnit *CU) {
.setMAttrs(mattrs)
.setEngineKind(EngineKind::JIT)
.setTargetOptions(CU->TT->tm->Options)
.setOptLevel(CodeGenOpt::Aggressive)
.setOptLevel(
#if LLVM_VERSION < 180
CodeGenOpt::Aggressive
#else
CodeGenOptLevel::Aggressive
#endif
)
.setMCJITMemoryManager(std::make_unique<TerraSectionMemoryManager>(CU))
#if LLVM_VERSION < 120
.setUseOrcMCJITReplacement(true)
Expand Down Expand Up @@ -545,7 +556,11 @@ class Types {
CreatePrimitiveType(typ, t);
} break;
case T_niltype: {
#if LLVM_VERSION < 170
t->type = Type::getInt8PtrTy(*CU->TT->ctx);
#else
t->type = PointerType::get(*CU->TT->ctx, 0);
#endif
} break;
case T_opaque: {
t->type = Type::getInt8Ty(*CU->TT->ctx);
Expand Down Expand Up @@ -586,7 +601,13 @@ class Types {
} break;
}
}
Type *FunctionPointerType() { return Type::getInt8PtrTy(*CU->TT->ctx); }
Type *FunctionPointerType() {
#if LLVM_VERSION < 170
return Type::getInt8PtrTy(*CU->TT->ctx);
#else
return PointerType::get(*CU->TT->ctx, 0);
#endif
}
bool LookupTypeCache(Obj *typ, TType **t) {
*t = (TType *)CU->symbols->getud(typ); // try to look up the cached type
if (*t == NULL) {
Expand Down Expand Up @@ -1673,7 +1694,9 @@ static CallingConv::ID ParseCallingConv(const char *cc) {
init = true;
ccmap["fastcc"] = CallingConv::Fast;
ccmap["coldcc"] = CallingConv::Cold;
#if LLVM_VERSION < 180
ccmap["webkit_jscc"] = CallingConv::WebKit_JS;
#endif
ccmap["anyregcc"] = CallingConv::AnyReg;
ccmap["preserve_mostcc"] = CallingConv::PreserveMost;
ccmap["preserve_allcc"] = CallingConv::PreserveAll;
Expand Down

0 comments on commit 0321fba

Please sign in to comment.