Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 1 | //===--- BPF.cpp - Implement BPF target feature support -------------------===// |
| 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 |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 6 | // |
| 7 | //===----------------------------------------------------------------------===// |
| 8 | // |
| 9 | // This file implements BPF TargetInfo objects. |
| 10 | // |
| 11 | //===----------------------------------------------------------------------===// |
| 12 | |
| 13 | #include "BPF.h" |
| 14 | #include "Targets.h" |
| 15 | #include "clang/Basic/MacroBuilder.h" |
Erich Keane | e44bdb3 | 2018-02-08 23:16:55 +0000 | [diff] [blame] | 16 | #include "llvm/ADT/StringRef.h" |
Erich Keane | ebba592 | 2017-07-21 22:37:03 +0000 | [diff] [blame] | 17 | |
| 18 | using namespace clang; |
| 19 | using namespace clang::targets; |
| 20 | |
| 21 | void BPFTargetInfo::getTargetDefines(const LangOptions &Opts, |
| 22 | MacroBuilder &Builder) const { |
| 23 | DefineStd(Builder, "bpf", Opts); |
| 24 | Builder.defineMacro("__BPF__"); |
| 25 | } |
Erich Keane | e44bdb3 | 2018-02-08 23:16:55 +0000 | [diff] [blame] | 26 | |
| 27 | static constexpr llvm::StringLiteral ValidCPUNames[] = {"generic", "v1", "v2", |
Jiong Wang | 862e740 | 2019-02-07 22:51:56 +0000 | [diff] [blame^] | 28 | "v3", "probe"}; |
Erich Keane | e44bdb3 | 2018-02-08 23:16:55 +0000 | [diff] [blame] | 29 | |
| 30 | bool BPFTargetInfo::isValidCPUName(StringRef Name) const { |
| 31 | return llvm::find(ValidCPUNames, Name) != std::end(ValidCPUNames); |
| 32 | } |
| 33 | |
| 34 | void BPFTargetInfo::fillValidCPUList(SmallVectorImpl<StringRef> &Values) const { |
| 35 | Values.append(std::begin(ValidCPUNames), std::end(ValidCPUNames)); |
| 36 | } |