1 | /** |
2 | * Copyright (c) 2017-present, Facebook, Inc. |
3 | * |
4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
5 | * you may not use this file except in compliance with the License. |
6 | * You may obtain a copy of the License at |
7 | * |
8 | * http://www.apache.org/licenses/LICENSE-2.0 |
9 | * |
10 | * Unless required by applicable law or agreed to in writing, software |
11 | * distributed under the License is distributed on an "AS IS" BASIS, |
12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 | * See the License for the specific language governing permissions and |
14 | * limitations under the License. |
15 | */ |
16 | |
17 | // This file includes some macros for some LLVM APIs that have changed across |
18 | // LLVM versions. This is to keep the code compatible with all LLVM versions. |
19 | #ifndef GLOW_IR_LLVMAPIMACROS_H |
20 | #define GLOW_IR_LLVMAPIMACROS_H |
21 | |
22 | #if LLVM_VERSION_MAJOR < 10 |
23 | #define SET_ALIGNMENT(value_ptr, arg) value_ptr->setAlignment(arg) |
24 | #elif LLVM_VERSION_MAJOR < 12 |
25 | #define SET_ALIGNMENT(value_ptr, arg) \ |
26 | value_ptr->setAlignment(llvm::MaybeAlign(arg)) |
27 | #else |
28 | #define SET_ALIGNMENT(value_ptr, arg) value_ptr->setAlignment(llvm::Align(arg)) |
29 | #endif |
30 | |
31 | #if LLVM_VERSION_MAJOR >= 12 |
32 | #define GET_TYPE_BY_NAME(module, arg) \ |
33 | llvm::StructType::getTypeByName(module.getContext(), arg) |
34 | #else |
35 | #define GET_TYPE_BY_NAME(module, arg) module.getTypeByName(arg) |
36 | #endif |
37 | |
38 | #endif // GLOW_IR_LLVMAPIMACROS_H |
39 | |