#include "BPF.h"
#include "BPFInstrInfo.h"
#include "BPFTargetMachine.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/LivePhysRegs.h"
#include "llvm/CodeGen/MachineFrameInfo.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
#include "llvm/CodeGen/MachineRegisterInfo.h"
#include "llvm/Support/Debug.h"
#include <set>
usingnamespacellvm;
#define DEBUG_TYPE …
static cl::opt<int> GotolAbsLowBound("gotol-abs-low-bound", cl::Hidden,
cl::init(INT16_MAX >> 1), cl::desc("Specify gotol lower bound"));
STATISTIC(ZExtElemNum, "Number of zero extension shifts eliminated");
namespace {
struct BPFMIPeephole : public MachineFunctionPass { … };
void BPFMIPeephole::initialize(MachineFunction &MFParm) { … }
bool BPFMIPeephole::isCopyFrom32Def(MachineInstr *CopyMI)
{ … }
bool BPFMIPeephole::isPhiFrom32Def(MachineInstr *PhiMI)
{ … }
bool BPFMIPeephole::isInsnFrom32Def(MachineInstr *DefInsn)
{ … }
bool BPFMIPeephole::isMovFrom32Def(MachineInstr *MovMI)
{ … }
bool BPFMIPeephole::eliminateZExtSeq() { … }
bool BPFMIPeephole::eliminateZExt() { … }
}
INITIALIZE_PASS(…)
char BPFMIPeephole::ID = …;
FunctionPass* llvm::createBPFMIPeepholePass() { … }
STATISTIC(RedundantMovElemNum, "Number of redundant moves eliminated");
namespace {
struct BPFMIPreEmitPeephole : public MachineFunctionPass { … };
void BPFMIPreEmitPeephole::initialize(MachineFunction &MFParm) { … }
bool BPFMIPreEmitPeephole::eliminateRedundantMov() { … }
bool BPFMIPreEmitPeephole::in16BitRange(int Num) { … }
bool BPFMIPreEmitPeephole::adjustBranch() { … }
static const unsigned CallerSavedRegs[] = …;
struct BPFFastCall { … };
static void collectBPFFastCalls(const TargetRegisterInfo *TRI,
LivePhysRegs &LiveRegs, MachineBasicBlock &BB,
SmallVectorImpl<BPFFastCall> &Calls) { … }
static int64_t computeMinFixedObjOffset(MachineFrameInfo &MFI,
unsigned SlotSize) { … }
bool BPFMIPreEmitPeephole::insertMissingCallerSavedSpills() { … }
}
INITIALIZE_PASS(…)
char BPFMIPreEmitPeephole::ID = …;
FunctionPass* llvm::createBPFMIPreEmitPeepholePass()
{ … }