LLVM: lib/CodeGen/PatchableFunction.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

23

24using namespace llvm;

25

26namespace {

27struct PatchableFunction {

28 bool run(MachineFunction &F);

29};

30

32 static char ID;

33 PatchableFunctionLegacy() : MachineFunctionPass(ID) {

35 }

36 bool runOnMachineFunction(MachineFunction &F) override {

37 return PatchableFunction().run(F);

38 }

39

40 MachineFunctionProperties getRequiredProperties() const override {

41 return MachineFunctionProperties().setNoVRegs();

42 }

43};

44

45}

46

51 if (!PatchableFunction().run(MF))

54}

55

58

61

63 TII->get(TargetOpcode::PATCHABLE_FUNCTION_ENTER));

64 return true;

66#ifndef NDEBUG

69 assert(PatchType == "prologue-short-redirect" && "Only possibility today!");

70#endif

73 TII->get(TargetOpcode::PATCHABLE_OP))

76 return true;

77 }

78 return false;

79}

80

81char PatchableFunctionLegacy::ID = 0;

83INITIALIZE_PASS(PatchableFunctionLegacy, "patchable-function",

84 "Implement the 'patchable-function' attribute", false, false)

assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")

const TargetInstrInfo & TII

#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)

Functions, function parameters, and return types can have attributes to indicate how they should be t...

LLVM_ABI StringRef getValueAsString() const

Return the attribute's value as a string.

Attribute getFnAttribute(Attribute::AttrKind Kind) const

Return the attribute for the given attribute kind.

bool hasFnAttribute(Attribute::AttrKind Kind) const

Return true if the function has the attribute.

An RAII based helper class to modify MachineFunctionProperties when running pass.

MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...

const TargetSubtargetInfo & getSubtarget() const

getSubtarget - Return the subtarget for which this machine code is being compiled.

void ensureAlignment(Align A)

ensureAlignment - Make sure the function is at least A bytes aligned.

Function & getFunction()

Return the LLVM function that this machine code represents.

const MachineInstrBuilder & addImm(int64_t Val) const

Add a new immediate operand.

static LLVM_ABI PassRegistry * getPassRegistry()

getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...

PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)

Definition PatchableFunction.cpp:48

A set of analyses that are preserved following a run of a transformation pass.

static PreservedAnalyses all()

Construct a special preserved set that preserves all passes.

StringRef - Represent a constant reference to a string, i.e.

TargetInstrInfo - Interface to description of machine instruction set.

virtual const TargetInstrInfo * getInstrInfo() const

PointerTypeMap run(const Module &M)

Compute the PointerTypeMap for the module M.

This is an optimization pass for GlobalISel generic memory operations.

MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)

Builder interface. Specify how to create the initial instruction itself.

LLVM_ABI char & PatchableFunctionID

This pass implements the "patchable-function" attribute.

Definition PatchableFunction.cpp:82

AnalysisManager< MachineFunction > MachineFunctionAnalysisManager

LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()

Returns the minimum set of Analyses that all machine function passes must preserve.

LLVM_ABI void initializePatchableFunctionLegacyPass(PassRegistry &)

This struct is a compact representation of a valid (non-zero power of two) alignment.