Skip to content

Commit c08080a

Browse files
committed
feat: switch the version of llvm to 14
1 parent 42481a3 commit c08080a

File tree

18 files changed

+325
-127
lines changed

18 files changed

+325
-127
lines changed

.github/workflows/build.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,8 @@ on:
1919
- '**'
2020

2121
env:
22-
LLVM_VERSION: 13.0.1
23-
LLVM_VERSION_MAJOR: 13
22+
LLVM_VERSION: 14.0.6
23+
LLVM_VERSION_MAJOR: 14
2424

2525
jobs:
2626
build:
@@ -43,7 +43,9 @@ jobs:
4343
check-latest: true
4444
- name: Install LLVM and Ninja on macOS
4545
if: startsWith(matrix.os, 'macos')
46-
run: brew install llvm@${{ env.LLVM_VERSION_MAJOR }} ninja
46+
run: |
47+
brew update
48+
brew install llvm@${{ env.LLVM_VERSION_MAJOR }} ninja
4749
- name: Install LLVM and Ninja on Ubuntu
4850
if: startsWith(matrix.os, 'ubuntu')
4951
run: |

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
cmake_minimum_required(VERSION 3.17)
22

3-
project(llvm-bindings CXX)
3+
project(llvm-bindings)
44

55
set(CMAKE_CXX_STANDARD 17)
66

README.md

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -8,16 +8,16 @@ LLVM bindings for Node.js/JavaScript/TypeScript
88

99
## Supported OS
1010

11-
| | x86_64 | ARM64 |
12-
| :---: | :---: | :---: |
13-
| macOS 10.15 Catalina | | / |
14-
| macOS 11 Big Sur || |
15-
| macOS 12 Monterey || |
16-
| Ubuntu 18.04 || |
17-
| Ubuntu 20.04 || |
18-
| Ubuntu 22.04 || |
19-
| Windows 10 || ⚠️ |
20-
| Windows 11 || ⚠️ |
11+
| | x86_64 | ARM64 |
12+
|:--------------------:|:------:|:-----:|
13+
| macOS 10.15 Catalina | | / |
14+
| macOS 11 Big Sur || |
15+
| macOS 12 Monterey || |
16+
| Ubuntu 18.04 || |
17+
| Ubuntu 20.04 || |
18+
| Ubuntu 22.04 || |
19+
| Windows 10 || ⚠️ |
20+
| Windows 11 || ⚠️ |
2121

2222
> ⚠️ means not tested.
2323
@@ -124,11 +124,12 @@ Due to the limitation of `node-addon-api`, this project has not implemented inhe
124124

125125
## Compatibility
126126

127-
| llvm-bindings versions | compatible LLVM versions |
128-
| ------------ | ------------ |
129-
| 0.0.x, 0.1.x | 11.0.x, 11.1.x |
130-
| 0.2.x | 12.0.x |
131-
| 0.3.x | 13.0.x |
127+
| llvm-bindings versions | compatible LLVM versions |
128+
|------------------------|--------------------------|
129+
| 0.0.x, 0.1.x | 11.0.x, 11.1.x |
130+
| 0.2.x | 12.0.x |
131+
| 0.3.x | 13.0.x |
132+
| 0.4.x | 14.0.x |
132133

133134
## Acknowledgments
134135
- [MichaReiser](https://github.com/MichaReiser): the creator of [llvm-node](https://github.com/MichaReiser/llvm-node)

cmake/LLVM.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ if (CMAKE_HOST_APPLE)
55
endforeach ()
66
endif ()
77

8-
find_package(LLVM 13 REQUIRED CONFIG)
8+
find_package(LLVM 14 REQUIRED CONFIG)
99

1010
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
1111

include/IR/DerivedTypes.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,6 @@ class PointerType : public Napi::ObjectWrap<PointerType> {
218218

219219
static Napi::Value getUnqual(const Napi::CallbackInfo &info);
220220

221-
Napi::Value getElementType(const Napi::CallbackInfo &info);
222-
223221
Napi::Value isPointerTy(const Napi::CallbackInfo &info);
224222

225223
Napi::Value isStructTy(const Napi::CallbackInfo &info);

include/IR/IRBuilder.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,4 +271,10 @@ class IRBuilder : public Napi::ObjectWrap<IRBuilder> {
271271
Napi::Value CreateInsertValue(const Napi::CallbackInfo &info);
272272

273273
Napi::Value CreateLandingPad(const Napi::CallbackInfo &info);
274+
275+
//===--------------------------------------------------------------------===//
276+
// Utility creation methods
277+
//===--------------------------------------------------------------------===//
278+
279+
Napi::Value CreatePtrDiff(const Napi::CallbackInfo &info);
274280
};

include/Support/TargetRegistry.h renamed to include/MC/TargetRegistry.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#pragma once
22

33
#include <napi.h>
4-
#include <llvm/Support/TargetRegistry.h>
4+
#include <llvm/MC/TargetRegistry.h>
55

66
class Target : public Napi::ObjectWrap<Target> {
77
public:

include/MC/index.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#pragma once
2+
3+
#include <napi.h>
4+
#include "MC/TargetRegistry.h"
5+
6+
void InitMC(Napi::Env env, Napi::Object &exports);

include/Support/index.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22

33
#include <napi.h>
44
#include "Support/SourceMgr.h"
5-
#include "Support/TargetRegistry.h"
65
#include "Support/TargetSelect.h"
76

87
void InitSupport(Napi::Env env, Napi::Object &exports);

include/Util/ErrMsg.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,7 @@ namespace ErrMsg {
433433
constexpr const char *CreateExtractValue = "IRBuilder.CreateExtractValue needs to be called with (agg: Value, idxs: number[], name?: string)";
434434
constexpr const char *CreateInsertValue = "IRBuilder.CreateInsertValue needs to be called with (agg: Value, value: Value, idxs: number[], name?: string)";
435435
constexpr const char *CreateLandingPad = "IRBuilder.CreateLandingPad needs to be called with (type: Type, numClauses: number, name?: string)";
436-
436+
constexpr const char *CreatePtrDiff = "IRBuilder.CreatePtrDiff needs to be called with (elemType: Type, lhs: Value, rhs: Value, name?: string)";
437437
}
438438
namespace Metadata {
439439
constexpr const char *constructor = "Metadata.constructor needs to be called with new (external: Napi::External<llvm::Metadata>)";

llvm-bindings.d.ts

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -412,8 +412,6 @@ declare namespace llvm {
412412

413413
public static getUnqual(elementType: Type): PointerType;
414414

415-
public getElementType(): Type;
416-
417415
// duplicated
418416
public isPointerTy(): boolean;
419417

@@ -1554,7 +1552,7 @@ declare namespace llvm {
15541552

15551553
public CreateIsNotNull(value: Value, name?: string): Value;
15561554

1557-
public CreatePtrDiff(lhs: Value, rhs: Value, name?: string): Value;
1555+
public CreatePtrDiff(elemType: Type, lhs: Value, rhs: Value, name?: string): Value;
15581556
}
15591557

15601558
namespace IRBuilder {
@@ -1768,6 +1766,8 @@ declare namespace llvm {
17681766
const addressofreturnaddress: number;
17691767
const adjust_trampoline: number;
17701768
const annotation: number;
1769+
const arithmetic_fence: number;
1770+
const asan_check_memaccess: number;
17711771
const assume: number;
17721772
const bitreverse: number;
17731773
const bswap: number;
@@ -1781,13 +1781,15 @@ declare namespace llvm {
17811781
const convert_from_fp16: number;
17821782
const convert_to_fp16: number;
17831783
const copysign: number;
1784+
const coro_align: number;
17841785
const coro_alloc: number;
17851786
const coro_alloca_alloc: number;
17861787
const coro_alloca_free: number;
17871788
const coro_alloca_get: number;
17881789
const coro_async_context_alloc: number;
17891790
const coro_async_context_dealloc: number;
17901791
const coro_async_resume: number;
1792+
const coro_async_size_replace: number;
17911793
const coro_begin: number;
17921794
const coro_destroy: number;
17931795
const coro_done: number;
@@ -1800,7 +1802,6 @@ declare namespace llvm {
18001802
const coro_id_retcon: number;
18011803
const coro_id_retcon_once: number;
18021804
const coro_noop: number;
1803-
const coro_param: number;
18041805
const coro_prepare_async: number;
18051806
const coro_prepare_retcon: number;
18061807
const coro_promise: number;
@@ -1858,6 +1859,7 @@ declare namespace llvm {
18581859
const hwasan_check_memaccess_shortgranules: number;
18591860
const icall_branch_funnel: number;
18601861
const init_trampoline: number;
1862+
const instrprof_cover: number;
18611863
const instrprof_increment: number;
18621864
const instrprof_increment_step: number;
18631865
const instrprof_value_profile: number;
@@ -1910,6 +1912,7 @@ declare namespace llvm {
19101912
const objc_autoreleasePoolPop: number;
19111913
const objc_autoreleasePoolPush: number;
19121914
const objc_autoreleaseReturnValue: number;
1915+
const objc_clang_arc_noop_use: number;
19131916
const objc_clang_arc_use: number;
19141917
const objc_copyWeak: number;
19151918
const objc_destroyWeak: number;
@@ -1942,6 +1945,12 @@ declare namespace llvm {
19421945
const preserve_union_access_index: number;
19431946
const pseudoprobe: number;
19441947
const ptr_annotation: number;
1948+
const ptrauth_auth: number;
1949+
const ptrauth_blend: number;
1950+
const ptrauth_resign: number;
1951+
const ptrauth_sign: number;
1952+
const ptrauth_sign_generic: number;
1953+
const ptrauth_strip: number;
19451954
const ptrmask: number;
19461955
const read_register: number;
19471956
const read_volatile_register: number;
@@ -1954,7 +1963,12 @@ declare namespace llvm {
19541963
const sadd_with_overflow: number;
19551964
const sdiv_fix: number;
19561965
const sdiv_fix_sat: number;
1966+
const seh_scope_begin: number;
1967+
const seh_scope_end: number;
1968+
const seh_try_begin: number;
1969+
const seh_try_end: number;
19571970
const set_loop_iterations: number;
1971+
const set_rounding: number;
19581972
const sideeffect: number;
19591973
const sin: number;
19601974
const smax: number;
@@ -1974,7 +1988,9 @@ declare namespace llvm {
19741988
const stacksave: number;
19751989
const start_loop_iterations: number;
19761990
const strip_invariant_group: number;
1991+
const swift_async_context_addr: number;
19771992
const test_set_loop_iterations: number;
1993+
const test_start_loop_iterations: number;
19781994
const thread_pointer: number;
19791995
const trap: number;
19801996
const trunc: number;
@@ -2013,12 +2029,36 @@ declare namespace llvm {
20132029
const vp_add: number;
20142030
const vp_and: number;
20152031
const vp_ashr: number;
2032+
const vp_fadd: number;
2033+
const vp_fdiv: number;
2034+
const vp_fmul: number;
2035+
const vp_frem: number;
2036+
const vp_fsub: number;
2037+
const vp_gather: number;
2038+
const vp_load: number;
20162039
const vp_lshr: number;
2040+
const vp_merge: number;
20172041
const vp_mul: number;
20182042
const vp_or: number;
2043+
const vp_reduce_add: number;
2044+
const vp_reduce_and: number;
2045+
const vp_reduce_fadd: number;
2046+
const vp_reduce_fmax: number;
2047+
const vp_reduce_fmin: number;
2048+
const vp_reduce_fmul: number;
2049+
const vp_reduce_mul: number;
2050+
const vp_reduce_or: number;
2051+
const vp_reduce_smax: number;
2052+
const vp_reduce_smin: number;
2053+
const vp_reduce_umax: number;
2054+
const vp_reduce_umin: number;
2055+
const vp_reduce_xor: number;
2056+
const vp_scatter: number;
20192057
const vp_sdiv: number;
2058+
const vp_select: number;
20202059
const vp_shl: number;
20212060
const vp_srem: number;
2061+
const vp_store: number;
20222062
const vp_sub: number;
20232063
const vp_udiv: number;
20242064
const vp_urem: number;
@@ -2041,10 +2081,6 @@ declare namespace llvm {
20412081
public static linkModules(destModule: Module, srcModule: Module): boolean;
20422082
}
20432083

2044-
class SMDiagnostic {
2045-
public constructor();
2046-
}
2047-
20482084
class Target {
20492085
public createTargetMachine(targetTriple: string, cpu: string, features?: string): TargetMachine;
20502086

@@ -2061,6 +2097,10 @@ declare namespace llvm {
20612097
protected constructor();
20622098
}
20632099

2100+
class SMDiagnostic {
2101+
public constructor();
2102+
}
2103+
20642104
class TargetMachine {
20652105
public createDataLayout(): DataLayout;
20662106

src/IR/DerivedTypes.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -560,7 +560,6 @@ void PointerType::Init(Napi::Env env, Napi::Object &exports) {
560560
Napi::Function func = DefineClass(env, "PointerType", {
561561
StaticMethod("get", &PointerType::get),
562562
StaticMethod("getUnqual", &PointerType::getUnqual),
563-
InstanceMethod("getElementType", &PointerType::getElementType),
564563
InstanceMethod("isPointerTy", &PointerType::isPointerTy),
565564
InstanceMethod("isStructTy", &PointerType::isStructTy),
566565
InstanceMethod("isIntegerTy", &PointerType::isIntegerTy),
@@ -619,12 +618,6 @@ Napi::Value PointerType::getUnqual(const Napi::CallbackInfo &info) {
619618
return PointerType::New(env, pointerType);
620619
}
621620

622-
Napi::Value PointerType::getElementType(const Napi::CallbackInfo &info) {
623-
Napi::Env env = info.Env();
624-
llvm::Type *elementType = pointerType->getElementType();
625-
return Type::New(env, elementType);
626-
}
627-
628621
Napi::Value PointerType::isPointerTy(const Napi::CallbackInfo &info) {
629622
return Napi::Boolean::New(info.Env(), pointerType->isPointerTy());
630623
}

src/IR/IRBuilder.cpp

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -177,8 +177,7 @@ void IRBuilder::Init(Napi::Env env, Napi::Object &exports) {
177177
//===--------------------------------------------------------------------===//
178178

179179
InstanceMethod("CreateIsNull", &IRBuilder::unOpFactory<&LLVMIRBuilder::CreateIsNull>),
180-
InstanceMethod("CreateIsNotNull", &IRBuilder::unOpFactory<&LLVMIRBuilder::CreateIsNotNull>),
181-
InstanceMethod("CreatePtrDiff", &IRBuilder::binOpFactory<&LLVMIRBuilder::CreatePtrDiff>)
180+
InstanceMethod("CreateIsNotNull", &IRBuilder::unOpFactory<&LLVMIRBuilder::CreateIsNotNull>)
182181
});
183182
constructor = Napi::Persistent(func);
184183
constructor.SuppressDestruct();
@@ -823,3 +822,22 @@ Napi::Value IRBuilder::CreateLandingPad(const Napi::CallbackInfo &info) {
823822
}
824823
throw Napi::TypeError::New(env, ErrMsg::Class::IRBuilder::CreateLandingPad);
825824
}
825+
826+
//===--------------------------------------------------------------------===//
827+
// Utility creation methods
828+
//===--------------------------------------------------------------------===//
829+
830+
Napi::Value IRBuilder::CreatePtrDiff(const Napi::CallbackInfo &info) {
831+
Napi::Env env = info.Env();
832+
unsigned argsLen = info.Length();
833+
if (argsLen == 3 && Type::IsClassOf(info[0]) && Value::IsClassOf(info[1]) && Value::IsClassOf(info[2]) ||
834+
argsLen == 4 && Type::IsClassOf(info[0]) && Value::IsClassOf(info[1]) && Value::IsClassOf(info[2]) && info[3].IsString()) {
835+
llvm::Type *elementType = Type::Extract(info[0]);
836+
llvm::Value *lhs = Value::Extract(info[1]);
837+
llvm::Value *rhs = Value::Extract(info[2]);
838+
const std::string &name = argsLen == 4 ? std::string(info[3].As<Napi::String>()) : "";
839+
llvm::Value *diff = builder->CreatePtrDiff(elementType, lhs, rhs, name);
840+
return Value::New(env, diff);
841+
}
842+
throw Napi::TypeError::New(env, ErrMsg::Class::IRBuilder::CreatePtrDiff);
843+
}

0 commit comments

Comments
 (0)