LLVM: lib/Target/X86/X86InsertWait.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

32

33using namespace llvm;

34

35#define DEBUG_TYPE "x86-insert-wait"

36

37namespace {

38

40public:

41 static char ID;

42

44

46

47 StringRef getPassName() const override {

48 return "X86 insert wait instruction";

49 }

50};

51

52}

53

54char WaitInsert::ID = 0;

55

57

59 switch (MI.getOpcode()) {

60 case X86::FNINIT:

61 case X86::FLDCW16m:

62 case X86::FNSTCW16m:

63 case X86::FNSTSW16r:

64 case X86::FNSTSWm:

65 case X86::FNCLEX:

66 case X86::FLDENVm:

67 case X86::FSTENVm:

68 case X86::FRSTORm:

69 case X86::FSAVEm:

70 case X86::FINCSTP:

71 case X86::FDECSTP:

72 case X86::FFREE:

73 case X86::FFREEP:

74 case X86::FNOP:

75 case X86::WAIT:

76 return true;

77 default:

78 return false;

79 }

80}

81

83

84 switch (MI.getOpcode()) {

85 case X86::FNINIT:

86 case X86::FNSTSW16r:

87 case X86::FNSTSWm:

88 case X86::FNSTCW16m:

89 case X86::FNCLEX:

90 return true;

91 default:

92 return false;

93 }

94}

95

96bool WaitInsert::runOnMachineFunction(MachineFunction &MF) {

98 return false;

99

100 const X86Subtarget &ST = MF.getSubtarget();

101 const X86InstrInfo *TII = ST.getInstrInfo();

103

104 for (MachineBasicBlock &MBB : MF) {

106

108 continue;

109

110

111

112 if (!(MI->mayRaiseFPException() || MI->mayLoadOrStore()) ||

114 continue;

115

116

120 continue;

121

122 BuildMI(MBB, AfterMI, MI->getDebugLoc(), TII->get(X86::WAIT));

124

125 ++MI;

127 }

128 }

130}

const HexagonInstrInfo * TII

static bool isX87ControlInstruction(MachineInstr &MI)

Definition X86InsertWait.cpp:58

static bool isX87NonWaitingControlInstruction(MachineInstr &MI)

Definition X86InsertWait.cpp:82

FunctionPass class - This class is used to implement most global optimizations.

bool hasFnAttribute(Attribute::AttrKind Kind) const

Return true if the function has the attribute.

MachineInstrBundleIterator< MachineInstr > iterator

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.

Function & getFunction()

Return the LLVM function that this machine code represents.

Representation of each machine instruction.

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

unsigned ID

LLVM IR allows to use arbitrary numbers as calling convention identifiers.

bool isX87Instruction(MachineInstr &MI)

Check if the instruction is X87 instruction.

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.

FunctionPass * createX86InsertX87waitPass()

This pass insert wait instruction after X87 instructions which could raise fp exceptions when strict-...

Definition X86InsertWait.cpp:56

LLVM_ABI raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.