1*9880d681SAndroid Build Coastguard Worker //===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===// 2*9880d681SAndroid Build Coastguard Worker // 3*9880d681SAndroid Build Coastguard Worker // The LLVM Compiler Infrastructure 4*9880d681SAndroid Build Coastguard Worker // 5*9880d681SAndroid Build Coastguard Worker // This file is distributed under the University of Illinois Open Source 6*9880d681SAndroid Build Coastguard Worker // License. See LICENSE.TXT for details. 7*9880d681SAndroid Build Coastguard Worker // 8*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 9*9880d681SAndroid Build Coastguard Worker // 10*9880d681SAndroid Build Coastguard Worker // This file defines a wrapper class for the 'Intrinsic' TableGen class. 11*9880d681SAndroid Build Coastguard Worker // 12*9880d681SAndroid Build Coastguard Worker //===----------------------------------------------------------------------===// 13*9880d681SAndroid Build Coastguard Worker 14*9880d681SAndroid Build Coastguard Worker #ifndef LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H 15*9880d681SAndroid Build Coastguard Worker #define LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H 16*9880d681SAndroid Build Coastguard Worker 17*9880d681SAndroid Build Coastguard Worker #include "llvm/CodeGen/MachineValueType.h" 18*9880d681SAndroid Build Coastguard Worker #include <string> 19*9880d681SAndroid Build Coastguard Worker #include <vector> 20*9880d681SAndroid Build Coastguard Worker 21*9880d681SAndroid Build Coastguard Worker namespace llvm { 22*9880d681SAndroid Build Coastguard Worker class Record; 23*9880d681SAndroid Build Coastguard Worker class RecordKeeper; 24*9880d681SAndroid Build Coastguard Worker class CodeGenTarget; 25*9880d681SAndroid Build Coastguard Worker 26*9880d681SAndroid Build Coastguard Worker struct CodeGenIntrinsic { 27*9880d681SAndroid Build Coastguard Worker Record *TheDef; // The actual record defining this intrinsic. 28*9880d681SAndroid Build Coastguard Worker std::string Name; // The name of the LLVM function "llvm.bswap.i32" 29*9880d681SAndroid Build Coastguard Worker std::string EnumName; // The name of the enum "bswap_i32" 30*9880d681SAndroid Build Coastguard Worker std::string GCCBuiltinName; // Name of the corresponding GCC builtin, or "". 31*9880d681SAndroid Build Coastguard Worker std::string MSBuiltinName; // Name of the corresponding MS builtin, or "". 32*9880d681SAndroid Build Coastguard Worker std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics. 33*9880d681SAndroid Build Coastguard Worker 34*9880d681SAndroid Build Coastguard Worker /// This structure holds the return values and parameter values of an 35*9880d681SAndroid Build Coastguard Worker /// intrinsic. If the number of return values is > 1, then the intrinsic 36*9880d681SAndroid Build Coastguard Worker /// implicitly returns a first-class aggregate. The numbering of the types 37*9880d681SAndroid Build Coastguard Worker /// starts at 0 with the first return value and continues from there through 38*9880d681SAndroid Build Coastguard Worker /// the parameter list. This is useful for "matching" types. 39*9880d681SAndroid Build Coastguard Worker struct IntrinsicSignature { 40*9880d681SAndroid Build Coastguard Worker /// The MVT::SimpleValueType for each return type. Note that this list is 41*9880d681SAndroid Build Coastguard Worker /// only populated when in the context of a target .td file. When building 42*9880d681SAndroid Build Coastguard Worker /// Intrinsics.td, this isn't available, because we don't know the target 43*9880d681SAndroid Build Coastguard Worker /// pointer size. 44*9880d681SAndroid Build Coastguard Worker std::vector<MVT::SimpleValueType> RetVTs; 45*9880d681SAndroid Build Coastguard Worker 46*9880d681SAndroid Build Coastguard Worker /// The records for each return type. 47*9880d681SAndroid Build Coastguard Worker std::vector<Record *> RetTypeDefs; 48*9880d681SAndroid Build Coastguard Worker 49*9880d681SAndroid Build Coastguard Worker /// The MVT::SimpleValueType for each parameter type. Note that this list is 50*9880d681SAndroid Build Coastguard Worker /// only populated when in the context of a target .td file. When building 51*9880d681SAndroid Build Coastguard Worker /// Intrinsics.td, this isn't available, because we don't know the target 52*9880d681SAndroid Build Coastguard Worker /// pointer size. 53*9880d681SAndroid Build Coastguard Worker std::vector<MVT::SimpleValueType> ParamVTs; 54*9880d681SAndroid Build Coastguard Worker 55*9880d681SAndroid Build Coastguard Worker /// The records for each parameter type. 56*9880d681SAndroid Build Coastguard Worker std::vector<Record *> ParamTypeDefs; 57*9880d681SAndroid Build Coastguard Worker }; 58*9880d681SAndroid Build Coastguard Worker 59*9880d681SAndroid Build Coastguard Worker IntrinsicSignature IS; 60*9880d681SAndroid Build Coastguard Worker 61*9880d681SAndroid Build Coastguard Worker /// Bit flags describing the type (ref/mod) and location of memory 62*9880d681SAndroid Build Coastguard Worker /// accesses that may be performed by the intrinsics. Analogous to 63*9880d681SAndroid Build Coastguard Worker /// \c FunctionModRefBehaviour. 64*9880d681SAndroid Build Coastguard Worker enum ModRefBits { 65*9880d681SAndroid Build Coastguard Worker /// The intrinsic may access memory anywhere, i.e. it is not restricted 66*9880d681SAndroid Build Coastguard Worker /// to access through pointer arguments. 67*9880d681SAndroid Build Coastguard Worker MR_Anywhere = 1, 68*9880d681SAndroid Build Coastguard Worker 69*9880d681SAndroid Build Coastguard Worker /// The intrinsic may read memory. 70*9880d681SAndroid Build Coastguard Worker MR_Ref = 2, 71*9880d681SAndroid Build Coastguard Worker 72*9880d681SAndroid Build Coastguard Worker /// The intrinsic may write memory. 73*9880d681SAndroid Build Coastguard Worker MR_Mod = 4, 74*9880d681SAndroid Build Coastguard Worker 75*9880d681SAndroid Build Coastguard Worker /// The intrinsic may both read and write memory. 76*9880d681SAndroid Build Coastguard Worker MR_ModRef = MR_Ref | MR_Mod, 77*9880d681SAndroid Build Coastguard Worker }; 78*9880d681SAndroid Build Coastguard Worker 79*9880d681SAndroid Build Coastguard Worker /// Memory mod/ref behavior of this intrinsic, corresponding to intrinsic 80*9880d681SAndroid Build Coastguard Worker /// properties (IntrReadMem, IntrArgMemOnly, etc.). 81*9880d681SAndroid Build Coastguard Worker enum ModRefBehavior { 82*9880d681SAndroid Build Coastguard Worker NoMem = 0, 83*9880d681SAndroid Build Coastguard Worker ReadArgMem = MR_Ref, 84*9880d681SAndroid Build Coastguard Worker ReadMem = MR_Ref | MR_Anywhere, 85*9880d681SAndroid Build Coastguard Worker WriteArgMem = MR_Mod, 86*9880d681SAndroid Build Coastguard Worker WriteMem = MR_Mod | MR_Anywhere, 87*9880d681SAndroid Build Coastguard Worker ReadWriteArgMem = MR_ModRef, 88*9880d681SAndroid Build Coastguard Worker ReadWriteMem = MR_ModRef | MR_Anywhere, 89*9880d681SAndroid Build Coastguard Worker }; 90*9880d681SAndroid Build Coastguard Worker ModRefBehavior ModRef; 91*9880d681SAndroid Build Coastguard Worker 92*9880d681SAndroid Build Coastguard Worker /// This is set to true if the intrinsic is overloaded by its argument 93*9880d681SAndroid Build Coastguard Worker /// types. 94*9880d681SAndroid Build Coastguard Worker bool isOverloaded; 95*9880d681SAndroid Build Coastguard Worker 96*9880d681SAndroid Build Coastguard Worker /// True if the intrinsic is commutative. 97*9880d681SAndroid Build Coastguard Worker bool isCommutative; 98*9880d681SAndroid Build Coastguard Worker 99*9880d681SAndroid Build Coastguard Worker /// True if the intrinsic can throw. 100*9880d681SAndroid Build Coastguard Worker bool canThrow; 101*9880d681SAndroid Build Coastguard Worker 102*9880d681SAndroid Build Coastguard Worker /// True if the intrinsic is marked as noduplicate. 103*9880d681SAndroid Build Coastguard Worker bool isNoDuplicate; 104*9880d681SAndroid Build Coastguard Worker 105*9880d681SAndroid Build Coastguard Worker /// True if the intrinsic is no-return. 106*9880d681SAndroid Build Coastguard Worker bool isNoReturn; 107*9880d681SAndroid Build Coastguard Worker 108*9880d681SAndroid Build Coastguard Worker /// True if the intrinsic is marked as convergent. 109*9880d681SAndroid Build Coastguard Worker bool isConvergent; 110*9880d681SAndroid Build Coastguard Worker 111*9880d681SAndroid Build Coastguard Worker enum ArgAttribute { NoCapture, Returned, ReadOnly, WriteOnly, ReadNone }; 112*9880d681SAndroid Build Coastguard Worker std::vector<std::pair<unsigned, ArgAttribute>> ArgumentAttributes; 113*9880d681SAndroid Build Coastguard Worker 114*9880d681SAndroid Build Coastguard Worker CodeGenIntrinsic(Record *R); 115*9880d681SAndroid Build Coastguard Worker }; 116*9880d681SAndroid Build Coastguard Worker 117*9880d681SAndroid Build Coastguard Worker /// Read all of the intrinsics defined in the specified .td file. 118*9880d681SAndroid Build Coastguard Worker std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC, 119*9880d681SAndroid Build Coastguard Worker bool TargetOnly); 120*9880d681SAndroid Build Coastguard Worker } 121*9880d681SAndroid Build Coastguard Worker 122*9880d681SAndroid Build Coastguard Worker #endif 123