1193323Sed//===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===//
2193323Sed//
3193323Sed//                     The LLVM Compiler Infrastructure
4193323Sed//
5193323Sed// This file is distributed under the University of Illinois Open Source
6193323Sed// License. See LICENSE.TXT for details.
7193323Sed//
8193323Sed//===----------------------------------------------------------------------===//
9193323Sed//
10193323Sed// This file defines a wrapper class for the 'Intrinsic' TableGen class.
11193323Sed//
12193323Sed//===----------------------------------------------------------------------===//
13193323Sed
14280031Sdim#ifndef LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H
15280031Sdim#define LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H
16193323Sed
17276479Sdim#include "llvm/CodeGen/MachineValueType.h"
18193323Sed#include <string>
19193323Sed#include <vector>
20193323Sed
21193323Sednamespace llvm {
22193323Sed  class Record;
23193323Sed  class RecordKeeper;
24193323Sed  class CodeGenTarget;
25193323Sed
26193323Sed  struct CodeGenIntrinsic {
27193323Sed    Record *TheDef;            // The actual record defining this intrinsic.
28193323Sed    std::string Name;          // The name of the LLVM function "llvm.bswap.i32"
29193323Sed    std::string EnumName;      // The name of the enum "bswap_i32"
30193323Sed    std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "".
31276479Sdim    std::string MSBuiltinName; // Name of the corresponding MS builtin, or "".
32193323Sed    std::string TargetPrefix;  // Target prefix, e.g. "ppc" for t-s intrinsics.
33193323Sed
34193323Sed    /// IntrinsicSignature - This structure holds the return values and
35193323Sed    /// parameter values of an intrinsic. If the number of return values is > 1,
36193323Sed    /// then the intrinsic implicitly returns a first-class aggregate. The
37193323Sed    /// numbering of the types starts at 0 with the first return value and
38193323Sed    /// continues from there through the parameter list. This is useful for
39193323Sed    /// "matching" types.
40193323Sed    struct IntrinsicSignature {
41193323Sed      /// RetVTs - The MVT::SimpleValueType for each return type. Note that this
42193323Sed      /// list is only populated when in the context of a target .td file. When
43193323Sed      /// building Intrinsics.td, this isn't available, because we don't know
44193323Sed      /// the target pointer size.
45193323Sed      std::vector<MVT::SimpleValueType> RetVTs;
46193323Sed
47193323Sed      /// RetTypeDefs - The records for each return type.
48193323Sed      std::vector<Record*> RetTypeDefs;
49193323Sed
50193323Sed      /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that
51193323Sed      /// this list is only populated when in the context of a target .td file.
52193323Sed      /// When building Intrinsics.td, this isn't available, because we don't
53193323Sed      /// know the target pointer size.
54193323Sed      std::vector<MVT::SimpleValueType> ParamVTs;
55193323Sed
56193323Sed      /// ParamTypeDefs - The records for each parameter type.
57193323Sed      std::vector<Record*> ParamTypeDefs;
58193323Sed    };
59193323Sed
60193323Sed    IntrinsicSignature IS;
61193323Sed
62193323Sed    // Memory mod/ref behavior of this intrinsic.
63296417Sdim    enum ModRefKind {
64212904Sdim      NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem
65296417Sdim    };
66296417Sdim    ModRefKind ModRef;
67193323Sed
68193323Sed    /// This is set to true if the intrinsic is overloaded by its argument
69193323Sed    /// types.
70193323Sed    bool isOverloaded;
71193323Sed
72193323Sed    /// isCommutative - True if the intrinsic is commutative.
73193323Sed    bool isCommutative;
74223017Sdim
75223017Sdim    /// canThrow - True if the intrinsic can throw.
76223017Sdim    bool canThrow;
77239462Sdim
78276479Sdim    /// isNoDuplicate - True if the intrinsic is marked as noduplicate.
79276479Sdim    bool isNoDuplicate;
80276479Sdim
81239462Sdim    /// isNoReturn - True if the intrinsic is no-return.
82239462Sdim    bool isNoReturn;
83239462Sdim
84288943Sdim    /// isConvergent - True if the intrinsic is marked as convergent.
85288943Sdim    bool isConvergent;
86288943Sdim
87193323Sed    enum ArgAttribute {
88261991Sdim      NoCapture,
89261991Sdim      ReadOnly,
90261991Sdim      ReadNone
91193323Sed    };
92193323Sed    std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes;
93193323Sed
94193323Sed    CodeGenIntrinsic(Record *R);
95193323Sed  };
96193323Sed
97193323Sed  /// LoadIntrinsics - Read all of the intrinsics defined in the specified
98193323Sed  /// .td file.
99193323Sed  std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC,
100193323Sed                                               bool TargetOnly);
101193323Sed}
102193323Sed
103193323Sed#endif
104