LLVM 18.0.0git
BPFSubtarget.cpp
Go to the documentation of this file.
1//===-- BPFSubtarget.cpp - BPF Subtarget Information ----------------------===//
2//
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
6//
7//===----------------------------------------------------------------------===//
8//
9// This file implements the BPF specific subclass of TargetSubtargetInfo.
10//
11//===----------------------------------------------------------------------===//
12
13#include "BPFSubtarget.h"
14#include "BPF.h"
17
18using namespace llvm;
19
20#define DEBUG_TYPE "bpf-subtarget"
21
22#define GET_SUBTARGETINFO_TARGET_DESC
23#define GET_SUBTARGETINFO_CTOR
24#include "BPFGenSubtargetInfo.inc"
25
26static cl::opt<bool> Disable_ldsx("disable-ldsx", cl::Hidden, cl::init(false),
27 cl::desc("Disable ldsx insns"));
28static cl::opt<bool> Disable_movsx("disable-movsx", cl::Hidden, cl::init(false),
29 cl::desc("Disable movsx insns"));
30static cl::opt<bool> Disable_bswap("disable-bswap", cl::Hidden, cl::init(false),
31 cl::desc("Disable bswap insns"));
32static cl::opt<bool> Disable_sdiv_smod("disable-sdiv-smod", cl::Hidden,
33 cl::init(false), cl::desc("Disable sdiv/smod insns"));
34static cl::opt<bool> Disable_gotol("disable-gotol", cl::Hidden, cl::init(false),
35 cl::desc("Disable gotol insn"));
36static cl::opt<bool>
37 Disable_StoreImm("disable-storeimm", cl::Hidden, cl::init(false),
38 cl::desc("Disable BPF_ST (immediate store) insn"));
39
40void BPFSubtarget::anchor() {}
41
43 StringRef FS) {
44 initializeEnvironment();
45 initSubtargetFeatures(CPU, FS);
46 ParseSubtargetFeatures(CPU, /*TuneCPU*/ CPU, FS);
47 return *this;
48}
49
50void BPFSubtarget::initializeEnvironment() {
51 HasJmpExt = false;
52 HasJmp32 = false;
53 HasAlu32 = false;
54 UseDwarfRIS = false;
55 HasLdsx = false;
56 HasMovsx = false;
57 HasBswap = false;
58 HasSdivSmod = false;
59 HasGotol = false;
60 HasStoreImm = false;
61}
62
63void BPFSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {
64 if (CPU == "probe")
66 if (CPU == "generic" || CPU == "v1")
67 return;
68 if (CPU == "v2") {
69 HasJmpExt = true;
70 return;
71 }
72 if (CPU == "v3") {
73 HasJmpExt = true;
74 HasJmp32 = true;
75 HasAlu32 = true;
76 return;
77 }
78 if (CPU == "v4") {
79 HasJmpExt = true;
80 HasJmp32 = true;
81 HasAlu32 = true;
88 return;
89 }
90}
91
92BPFSubtarget::BPFSubtarget(const Triple &TT, const std::string &CPU,
93 const std::string &FS, const TargetMachine &TM)
94 : BPFGenSubtargetInfo(TT, CPU, /*TuneCPU*/ CPU, FS),
95 FrameLowering(initializeSubtargetDependencies(CPU, FS)),
96 TLInfo(TM, *this) {}
static cl::opt< bool > Disable_sdiv_smod("disable-sdiv-smod", cl::Hidden, cl::init(false), cl::desc("Disable sdiv/smod insns"))
static cl::opt< bool > Disable_ldsx("disable-ldsx", cl::Hidden, cl::init(false), cl::desc("Disable ldsx insns"))
static cl::opt< bool > Disable_gotol("disable-gotol", cl::Hidden, cl::init(false), cl::desc("Disable gotol insn"))
static cl::opt< bool > Disable_movsx("disable-movsx", cl::Hidden, cl::init(false), cl::desc("Disable movsx insns"))
static cl::opt< bool > Disable_StoreImm("disable-storeimm", cl::Hidden, cl::init(false), cl::desc("Disable BPF_ST (immediate store) insn"))
static cl::opt< bool > Disable_bswap("disable-bswap", cl::Hidden, cl::init(false), cl::desc("Disable bswap insns"))
const char LLVMTargetMachineRef TM
BPFSubtarget(const Triple &TT, const std::string &CPU, const std::string &FS, const TargetMachine &TM)
BPFSubtarget & initializeSubtargetDependencies(StringRef CPU, StringRef FS)
void ParseSubtargetFeatures(StringRef CPU, StringRef TuneCPU, StringRef FS)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
Primary interface to the complete machine description for the target machine.
Definition: TargetMachine.h:78
Triple - Helper class for working with autoconf configuration names.
Definition: Triple.h:44
initializer< Ty > init(const Ty &Val)
Definition: CommandLine.h:445
StringRef getHostCPUNameForBPF()
Definition: Host.cpp:420
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18