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