2015-05-27 14:44:32 -04:00
|
|
|
//===-- BPFSubtarget.cpp - BPF Subtarget Information ----------------------===//
|
|
|
|
|
//
|
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
|
//
|
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
//
|
|
|
|
|
// This file implements the BPF specific subclass of TargetSubtargetInfo.
|
|
|
|
|
//
|
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
|
|
|
|
|
#include "BPFSubtarget.h"
|
|
|
|
|
#include "BPF.h"
|
2017-12-18 15:10:56 -05:00
|
|
|
#include "llvm/Support/Host.h"
|
2015-05-27 14:44:32 -04:00
|
|
|
#include "llvm/Support/TargetRegistry.h"
|
|
|
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
|
|
#define DEBUG_TYPE "bpf-subtarget"
|
|
|
|
|
|
|
|
|
|
#define GET_SUBTARGETINFO_TARGET_DESC
|
|
|
|
|
#define GET_SUBTARGETINFO_CTOR
|
|
|
|
|
#include "BPFGenSubtargetInfo.inc"
|
|
|
|
|
|
|
|
|
|
void BPFSubtarget::anchor() {}
|
|
|
|
|
|
2017-12-18 15:10:56 -05:00
|
|
|
BPFSubtarget &BPFSubtarget::initializeSubtargetDependencies(StringRef CPU,
|
|
|
|
|
StringRef FS) {
|
|
|
|
|
initializeEnvironment();
|
|
|
|
|
initSubtargetFeatures(CPU, FS);
|
|
|
|
|
return *this;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BPFSubtarget::initializeEnvironment() {
|
|
|
|
|
HasJmpExt = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void BPFSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
|
|
|
|
|
if (CPU == "probe")
|
|
|
|
|
CPU = sys::detail::getHostCPUNameForBPF();
|
|
|
|
|
if (CPU == "generic" || CPU == "v1")
|
|
|
|
|
return;
|
|
|
|
|
if (CPU == "v2") {
|
|
|
|
|
HasJmpExt = true;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2015-06-21 09:59:01 -04:00
|
|
|
BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU,
|
2015-05-27 14:44:32 -04:00
|
|
|
const std::string &FS, const TargetMachine &TM)
|
2017-12-18 15:10:56 -05:00
|
|
|
: BPFGenSubtargetInfo(TT, CPU, FS), InstrInfo(),
|
|
|
|
|
FrameLowering(initializeSubtargetDependencies(CPU, FS)),
|
2015-08-07 19:01:33 -04:00
|
|
|
TLInfo(TM, *this) {}
|