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
14193323Sed#ifndef CODEGEN_INTRINSIC_H
15193323Sed#define CODEGEN_INTRINSIC_H
16193323Sed
17249423Sdim#include "llvm/CodeGen/ValueTypes.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 "".
31193323Sed    std::string TargetPrefix;  // Target prefix, e.g. "ppc" for t-s intrinsics.
32193323Sed
33193323Sed    /// IntrinsicSignature - This structure holds the return values and
34193323Sed    /// parameter values of an intrinsic. If the number of return values is > 1,
35193323Sed    /// then the intrinsic implicitly returns a first-class aggregate. The
36193323Sed    /// numbering of the types starts at 0 with the first return value and
37193323Sed    /// continues from there through the parameter list. This is useful for
38193323Sed    /// "matching" types.
39193323Sed    struct IntrinsicSignature {
40193323Sed      /// RetVTs - The MVT::SimpleValueType for each return type. Note that this
41193323Sed      /// list is only populated when in the context of a target .td file. When
42193323Sed      /// building Intrinsics.td, this isn't available, because we don't know
43193323Sed      /// the target pointer size.
44193323Sed      std::vector<MVT::SimpleValueType> RetVTs;
45193323Sed
46193323Sed      /// RetTypeDefs - The records for each return type.
47193323Sed      std::vector<Record*> RetTypeDefs;
48193323Sed
49193323Sed      /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that
50193323Sed      /// this list is only populated when in the context of a target .td file.
51193323Sed      /// When building Intrinsics.td, this isn't available, because we don't
52193323Sed      /// know the target pointer size.
53193323Sed      std::vector<MVT::SimpleValueType> ParamVTs;
54193323Sed
55193323Sed      /// ParamTypeDefs - The records for each parameter type.
56193323Sed      std::vector<Record*> ParamTypeDefs;
57193323Sed    };
58193323Sed
59193323Sed    IntrinsicSignature IS;
60193323Sed
61193323Sed    // Memory mod/ref behavior of this intrinsic.
62193323Sed    enum {
63212904Sdim      NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem
64193323Sed    } ModRef;
65193323Sed
66193323Sed    /// This is set to true if the intrinsic is overloaded by its argument
67193323Sed    /// types.
68193323Sed    bool isOverloaded;
69193323Sed
70193323Sed    /// isCommutative - True if the intrinsic is commutative.
71193323Sed    bool isCommutative;
72223017Sdim
73223017Sdim    /// canThrow - True if the intrinsic can throw.
74223017Sdim    bool canThrow;
75239462Sdim
76239462Sdim    /// isNoReturn - True if the intrinsic is no-return.
77239462Sdim    bool isNoReturn;
78239462Sdim
79193323Sed    enum ArgAttribute {
80263508Sdim      NoCapture,
81263508Sdim      ReadOnly,
82263508Sdim      ReadNone
83193323Sed    };
84193323Sed    std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes;
85193323Sed
86193323Sed    CodeGenIntrinsic(Record *R);
87193323Sed  };
88193323Sed
89193323Sed  /// LoadIntrinsics - Read all of the intrinsics defined in the specified
90193323Sed  /// .td file.
91193323Sed  std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC,
92193323Sed                                               bool TargetOnly);
93193323Sed}
94193323Sed
95193323Sed#endif
96