bpf: New target attribute "alu32" for 32-bit subregister support

This new attribute aims to control the enablement of 32-bit subregister
support on eBPF backend.

Name the interface as "alu32" is because we in particular want to enable
the generation of BPF_ALU32 instructions by enable subregister support.

This attribute could be used in the following format with llc:

  llc -mtriple=bpf -mattr=[+|-]alu32

It is disabled at default.

Signed-off-by: Jiong Wang <jiong.wang@netronome.com>
Reviewed-by: Yonghong Song <yhs@fb.com>
llvm-svn: 325982
This commit is contained in:
Yonghong Song 2018-02-23 23:49:22 +00:00
parent 0252f35362
commit 42389377d8
3 changed files with 9 additions and 0 deletions

View File

@ -26,6 +26,9 @@ def : Proc<"probe", []>;
def DummyFeature : SubtargetFeature<"dummy", "isDummyMode",
"true", "unused feature">;
def ALU32 : SubtargetFeature<"alu32", "HasAlu32", "true",
"Enable ALU32 instructions">;
def BPFInstPrinter : AsmWriter {
string AsmWriterClassName = "InstPrinter";
bit isMCAsmWriter = 1;

View File

@ -30,11 +30,13 @@ BPFSubtarget &BPFSubtarget::initializeSubtargetDependencies(StringRef CPU,
StringRef FS) {
initializeEnvironment();
initSubtargetFeatures(CPU, FS);
ParseSubtargetFeatures(CPU, FS);
return *this;
}
void BPFSubtarget::initializeEnvironment() {
HasJmpExt = false;
HasAlu32 = false;
}
void BPFSubtarget::initSubtargetFeatures(StringRef CPU, StringRef FS) {

View File

@ -47,6 +47,9 @@ protected:
// whether the cpu supports jmp ext
bool HasJmpExt;
// whether the cpu supports alu32 instructions.
bool HasAlu32;
public:
// This constructor initializes the data members to match that
// of the specified triple.
@ -59,6 +62,7 @@ public:
// subtarget options. Definition of function is auto generated by tblgen.
void ParseSubtargetFeatures(StringRef CPU, StringRef FS);
bool getHasJmpExt() const { return HasJmpExt; }
bool getHasAlu32() const { return HasAlu32; }
const BPFInstrInfo *getInstrInfo() const override { return &InstrInfo; }
const BPFFrameLowering *getFrameLowering() const override {