LLVM: include/llvm/Passes/OptimizationLevel.h Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15#ifndef LLVM_PASSES_OPTIMIZATIONLEVEL_H

16#define LLVM_PASSES_OPTIMIZATIONLEVEL_H

17

19#include <assert.h>

20

21namespace llvm {

22

23class OptimizationLevel final {

24 unsigned SpeedLevel = 2;

25 unsigned SizeLevel = 0;

27 : SpeedLevel(SpeedLevel), SizeLevel(SizeLevel) {

28

29 assert(SpeedLevel <= 3 &&

30 "Optimization level for speed should be 0, 1, 2, or 3");

31 assert(SizeLevel <= 2 &&

32 "Optimization level for size should be 0, 1, or 2");

33 assert((SizeLevel == 0 || SpeedLevel == 2) &&

34 "Optimize for size should be encoded with speedup level == 2");

35 }

36

37public:

39

40

41

43

44

45

46

47

48

49

50

51

52

53

54

55

56

57

59

60

61

62

63

64

65

66

67

68

69

70

71

72

73

74

76

77

78

79

80

81

82

83

84

85

86

87

88

89

91

92

93

94

95

96

97

98

99

100

102

103

104

105

106

107

108

110

112

114

116 return SizeLevel == Other.SizeLevel && SpeedLevel == Other.SpeedLevel;

117 }

119 return SizeLevel != Other.SizeLevel || SpeedLevel != Other.SpeedLevel;

120 }

121

123

125};

126}

127

128#endif

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

static LLVM_ABI const OptimizationLevel O3

Optimize for fast execution as much as possible.

Definition OptimizationLevel.h:90

bool operator==(const OptimizationLevel &Other) const

Definition OptimizationLevel.h:115

bool isOptimizingForSize() const

Definition OptimizationLevel.h:113

static LLVM_ABI const OptimizationLevel Oz

A very specialized mode that will optimize for code size at any and all costs.

Definition OptimizationLevel.h:109

OptimizationLevel()=default

static LLVM_ABI const OptimizationLevel O0

Disable as many optimizations as possible.

Definition OptimizationLevel.h:42

unsigned getSizeLevel() const

Definition OptimizationLevel.h:124

static LLVM_ABI const OptimizationLevel Os

Similar to O2 but tries to optimize for small code size instead of fast execution without triggering ...

Definition OptimizationLevel.h:101

bool operator!=(const OptimizationLevel &Other) const

Definition OptimizationLevel.h:118

unsigned getSpeedupLevel() const

Definition OptimizationLevel.h:122

static LLVM_ABI const OptimizationLevel O2

Optimize for fast execution as much as possible without triggering significant incremental compile ti...

Definition OptimizationLevel.h:75

bool isOptimizingForSpeed() const

Definition OptimizationLevel.h:111

static LLVM_ABI const OptimizationLevel O1

Optimize quickly without destroying debuggability.

Definition OptimizationLevel.h:58

This is an optimization pass for GlobalISel generic memory operations.