Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 1 | //===-- BPFTargetInfo.cpp - BPF Target Implementation ---------------------===// |
| 2 | // |
Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 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 |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | |
Richard Trieu | a68ee93 | 2019-05-14 22:54:06 +0000 | [diff] [blame] | 9 | #include "TargetInfo/BPFTargetInfo.h" |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 10 | #include "llvm/Support/TargetRegistry.h" |
Richard Trieu | a68ee93 | 2019-05-14 22:54:06 +0000 | [diff] [blame] | 11 | |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 12 | using namespace llvm; |
| 13 | |
Richard Trieu | a68ee93 | 2019-05-14 22:54:06 +0000 | [diff] [blame] | 14 | Target &llvm::getTheBPFleTarget() { |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 15 | static Target TheBPFleTarget; |
| 16 | return TheBPFleTarget; |
Alexei Starovoitov | 310dead | 2015-06-04 19:15:05 +0000 | [diff] [blame] | 17 | } |
Richard Trieu | a68ee93 | 2019-05-14 22:54:06 +0000 | [diff] [blame] | 18 | Target &llvm::getTheBPFbeTarget() { |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 19 | static Target TheBPFbeTarget; |
| 20 | return TheBPFbeTarget; |
| 21 | } |
Richard Trieu | a68ee93 | 2019-05-14 22:54:06 +0000 | [diff] [blame] | 22 | Target &llvm::getTheBPFTarget() { |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 23 | static Target TheBPFTarget; |
| 24 | return TheBPFTarget; |
| 25 | } |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 26 | |
Tom Stellard | 4b0b261 | 2019-06-11 03:21:13 +0000 | [diff] [blame] | 27 | extern "C" void LLVMInitializeBPFTargetInfo() { |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 28 | TargetRegistry::RegisterTarget(getTheBPFTarget(), "bpf", "BPF (host endian)", |
Daniel Sanders | 725584e | 2017-11-15 23:55:44 +0000 | [diff] [blame] | 29 | "BPF", [](Triple::ArchType) { return false; }, |
| 30 | true); |
| 31 | RegisterTarget<Triple::bpfel, /*HasJIT=*/true> X( |
| 32 | getTheBPFleTarget(), "bpfel", "BPF (little endian)", "BPF"); |
Mehdi Amini | f42454b | 2016-10-09 23:00:34 +0000 | [diff] [blame] | 33 | RegisterTarget<Triple::bpfeb, /*HasJIT=*/true> Y(getTheBPFbeTarget(), "bpfeb", |
Daniel Sanders | 725584e | 2017-11-15 23:55:44 +0000 | [diff] [blame] | 34 | "BPF (big endian)", "BPF"); |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 35 | } |