123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141 |
- #ifndef LLVM_UTILS_TABLEGEN_GIMATCHDAGPREDICATE_H
- #define LLVM_UTILS_TABLEGEN_GIMATCHDAGPREDICATE_H
- #include "llvm/ADT/StringRef.h"
- #include "GIMatchDag.h"
- namespace llvm {
- class CodeExpansions;
- class CodeGenInstruction;
- class GIMatchDagOperandList;
- class GIMatchDagContext;
- class raw_ostream;
- class GIMatchDagPredicate {
- public:
- enum GIMatchDagPredicateKind {
- GIMatchDagPredicateKind_Opcode,
- GIMatchDagPredicateKind_OneOfOpcodes,
- GIMatchDagPredicateKind_SameMO,
- };
- protected:
- const GIMatchDagPredicateKind Kind;
-
-
-
-
-
-
- StringRef Name;
-
-
- const GIMatchDagOperandList &OperandInfo;
- public:
- GIMatchDagPredicate(GIMatchDagPredicateKind Kind, StringRef Name,
- const GIMatchDagOperandList &OperandInfo)
- : Kind(Kind), Name(Name), OperandInfo(OperandInfo) {}
- virtual ~GIMatchDagPredicate() {}
- GIMatchDagPredicateKind getKind() const { return Kind; }
- StringRef getName() const { return Name; }
- const GIMatchDagOperandList &getOperandInfo() const { return OperandInfo; }
-
-
-
-
-
- virtual bool generateCheckCode(raw_ostream &OS, StringRef Indent,
- const CodeExpansions &Expansions) const {
- return false;
- }
- virtual void print(raw_ostream &OS) const;
- virtual void printDescription(raw_ostream &OS) const;
- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- virtual LLVM_DUMP_METHOD void dump() const { print(errs()); }
- #endif
- };
- class GIMatchDagOpcodePredicate : public GIMatchDagPredicate {
- const CodeGenInstruction &Instr;
- public:
- GIMatchDagOpcodePredicate(GIMatchDagContext &Ctx, StringRef Name,
- const CodeGenInstruction &Instr);
- static bool classof(const GIMatchDagPredicate *P) {
- return P->getKind() == GIMatchDagPredicateKind_Opcode;
- }
- const CodeGenInstruction *getInstr() const { return &Instr; }
- void printDescription(raw_ostream &OS) const override;
- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- virtual LLVM_DUMP_METHOD void dump() const override { print(errs()); }
- #endif
- };
- class GIMatchDagOneOfOpcodesPredicate : public GIMatchDagPredicate {
- SmallVector<const CodeGenInstruction *, 4> Instrs;
- public:
- GIMatchDagOneOfOpcodesPredicate(GIMatchDagContext &Ctx, StringRef Name);
- void addOpcode(const CodeGenInstruction *Instr) { Instrs.push_back(Instr); }
- static bool classof(const GIMatchDagPredicate *P) {
- return P->getKind() == GIMatchDagPredicateKind_OneOfOpcodes;
- }
- const SmallVectorImpl<const CodeGenInstruction *> &getInstrs() const {
- return Instrs;
- }
- void printDescription(raw_ostream &OS) const override;
- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- virtual LLVM_DUMP_METHOD void dump() const override { print(errs()); }
- #endif
- };
- class GIMatchDagSameMOPredicate : public GIMatchDagPredicate {
- public:
- GIMatchDagSameMOPredicate(GIMatchDagContext &Ctx, StringRef Name);
- static bool classof(const GIMatchDagPredicate *P) {
- return P->getKind() == GIMatchDagPredicateKind_SameMO;
- }
- void printDescription(raw_ostream &OS) const override;
- #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
- virtual LLVM_DUMP_METHOD void dump() const override { print(errs()); }
- #endif
- };
- raw_ostream &operator<<(raw_ostream &OS, const GIMatchDagPredicate &N);
- raw_ostream &operator<<(raw_ostream &OS, const GIMatchDagOpcodePredicate &N);
- }
- #endif
|