Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 1 | //===-- BPFSubtarget.cpp - BPF Subtarget Information ----------------------===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
| 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
| 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file implements the BPF specific subclass of TargetSubtargetInfo. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
| 14 | #include "BPFSubtarget.h" |
| 15 | #include "BPF.h" |
Yonghong Song | dc1dbf6 | 2017-08-23 04:25:57 +0000 | [diff] [blame] | 16 | #include "llvm/Support/Host.h" |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 17 | #include "llvm/Support/TargetRegistry.h" |
| 18 | |
| 19 | using namespace llvm; |
| 20 | |
| 21 | #define DEBUG_TYPE "bpf-subtarget" |
| 22 | |
| 23 | #define GET_SUBTARGETINFO_TARGET_DESC |
| 24 | #define GET_SUBTARGETINFO_CTOR |
| 25 | #include "BPFGenSubtargetInfo.inc" |
| 26 | |
| 27 | void BPFSubtarget::anchor() {} |
| 28 | |
Yonghong Song | dc1dbf6 | 2017-08-23 04:25:57 +0000 | [diff] [blame] | 29 | BPFSubtarget &BPFSubtarget::initializeSubtargetDependencies(StringRef CPU, |
| 30 | StringRef FS) { |
| 31 | initializeEnvironment(); |
| 32 | initSubtargetFeatures(CPU, FS); |
| 33 | return *this; |
| 34 | } |
| 35 | |
| 36 | void BPFSubtarget::initializeEnvironment() { |
| 37 | HasJmpExt = false; |
| 38 | } |
| 39 | |
| 40 | void BPFSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) { |
| 41 | if (CPU == "probe") |
| 42 | CPU = sys::detail::getHostCPUNameForBPF(); |
| 43 | if (CPU == "generic" || CPU == "v1") |
| 44 | return; |
| 45 | if (CPU == "v2") { |
| 46 | HasJmpExt = true; |
| 47 | return; |
| 48 | } |
| 49 | } |
| 50 | |
Daniel Sanders | a73f1fd | 2015-06-10 12:11:26 +0000 | [diff] [blame] | 51 | BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU, |
Alexei Starovoitov | e4c8c80 | 2015-01-24 17:51:26 +0000 | [diff] [blame] | 52 | const std::string &FS, const TargetMachine &TM) |
Yonghong Song | dc1dbf6 | 2017-08-23 04:25:57 +0000 | [diff] [blame] | 53 | : BPFGenSubtargetInfo(TT, CPU, FS), InstrInfo(), |
| 54 | FrameLowering(initializeSubtargetDependencies(CPU, FS)), |
Daniel Sanders | 50f1723 | 2015-09-15 16:17:27 +0000 | [diff] [blame] | 55 | TLInfo(TM, *this) {} |