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

1

2

3

4

5

6

7

8

9

10

11

23#include

24

25#define DEBUG_TYPE "gi-combiner"

26

27using namespace llvm;

28

29bool CombinerHelper::constantFoldICmp(const GICmp &ICmp,

34 return false;

35

37 LLT DstTy = MRI.getType(Dst);

38

40 return false;

41

45

47

49 if (Result)

51 DstTy.isVector(),

52 false));

53 else

54 B.buildConstant(Dst, 0);

55 };

56

57 return true;

58}

59

60bool CombinerHelper::constantFoldFCmp(const GFCmp &FCmp,

65 return false;

66

68 LLT DstTy = MRI.getType(Dst);

69

71 return false;

72

76

78

79 MatchInfo = [=](MachineIRBuilder &B) {

80 if (Result)

82 DstTy.isVector(),

83 true));

84 else

85 B.buildConstant(Dst, 0);

86 };

87

88 return true;

89}

90

94

95 Register Dst = Cmp->getReg(0);

96 Register LHS = Cmp->getLHSReg();

97 Register RHS = Cmp->getRHSReg();

98

103 return constantFoldICmp(*Cmp, *CLHS, *CRHS, MatchInfo);

104

105

108

109 MatchInfo = [=](MachineIRBuilder &B) { B.buildICmp(Pred, Dst, LHS, RHS); };

110 return true;

111 }

112

113 return false;

114}

115

119

120 Register Dst = Cmp->getReg(0);

121 Register LHS = Cmp->getLHSReg();

122 Register RHS = Cmp->getRHSReg();

123

126

129 return constantFoldFCmp(*Cmp, *CLHS, *CRHS, MatchInfo);

130

131

134

136 B.buildFCmp(Pred, Dst, LHS, RHS, Cmp->getFlags());

137 };

138 return true;

139 }

140

141 return false;

142}

unsigned const MachineRegisterInfo * MRI

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

static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")

This contains common combine transformations that may be used in a combine pass,or by the target else...

Declares convenience wrapper classes for interpreting MachineInstr instances as specific generic oper...

Interface for Targets to specify which operations they can successfully select and how the others sho...

This file declares the MachineIRBuilder class.

Promote Memory to Register

Class for arbitrary precision integers.

Predicate

This enumeration lists the possible predicates for CmpInst subclasses.

Predicate getSwappedPredicate() const

For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.

static bool isFPPredicate(Predicate P)

static bool isIntPredicate(Predicate P)

const TargetLowering & getTargetLowering() const

bool matchCanonicalizeFCmp(const MachineInstr &MI, BuildFnTy &MatchInfo) const

Definition CombinerHelperCompares.cpp:116

bool isConstantLegalOrBeforeLegalizer(const LLT Ty) const

MachineRegisterInfo & MRI

bool matchCanonicalizeICmp(const MachineInstr &MI, BuildFnTy &MatchInfo) const

Definition CombinerHelperCompares.cpp:91

static LLVM_ABI bool compare(const APFloat &LHS, const APFloat &RHS, FCmpInst::Predicate Pred)

Return result of LHS Pred RHS comparison.

CmpInst::Predicate getCond() const

An floating-point-like constant.

static LLVM_ABI std::optional< GFConstant > getConstant(Register Const, const MachineRegisterInfo &MRI)

GFConstantKind getKind() const

Returns the kind of of this constant, e.g, Scalar.

LLVM_ABI APFloat getScalarValue() const

Returns the value, if this constant is a scalar.

An integer-like constant.

LLVM_ABI APInt getScalarValue() const

Returns the value, if this constant is a scalar.

static LLVM_ABI std::optional< GIConstant > getConstant(Register Const, const MachineRegisterInfo &MRI)

GIConstantKind getKind() const

Returns the kind of of this constant, e.g, Scalar.

Register getReg(unsigned Idx) const

Access the Idx'th operand as a register and return it.

static LLVM_ABI bool compare(const APInt &LHS, const APInt &RHS, ICmpInst::Predicate Pred)

Return result of LHS Pred RHS comparison.

constexpr bool isVector() const

Helper class to build MachineInstr.

Representation of each machine instruction.

Wrapper class representing virtual and physical registers.

This is an optimization pass for GlobalISel generic memory operations.

std::function< void(MachineIRBuilder &)> BuildFnTy

LLVM_ABI int64_t getICmpTrueVal(const TargetLowering &TLI, bool IsVector, bool IsFP)

Returns an integer representing true, as defined by the TargetBooleanContents.

decltype(auto) cast(const From &Val)

cast - Return the argument parameter cast to the specified type.

void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)

Implement std::swap in terms of BitVector swap.