1324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===// 2324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 3324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// The LLVM Compiler Infrastructure 4324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 5324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// This file is distributed under the University of Illinois Open Source 6324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// License. See LICENSE.TXT for details. 7324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 8324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//===----------------------------------------------------------------------===// 9324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 10324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// This file defines a wrapper class for the 'Intrinsic' TableGen class. 11324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver// 12324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver//===----------------------------------------------------------------------===// 13324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 14324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#ifndef LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H 15324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#define LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H 16324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 17324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#include "llvm/CodeGen/MachineValueType.h" 18324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#include <string> 19324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#include <vector> 20324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 21324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruvernamespace llvm { 22324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver class Record; 23324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver class RecordKeeper; 24324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver class CodeGenTarget; 25324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 26324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver struct CodeGenIntrinsic { 27324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver Record *TheDef; // The actual record defining this intrinsic. 28324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::string Name; // The name of the LLVM function "llvm.bswap.i32" 29324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::string EnumName; // The name of the enum "bswap_i32" 30324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "". 31324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::string MSBuiltinName; // Name of the corresponding MS builtin, or "". 32324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics. 33324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 34324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// IntrinsicSignature - This structure holds the return values and 35324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// parameter values of an intrinsic. If the number of return values is > 1, 36324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// then the intrinsic implicitly returns a first-class aggregate. The 37324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// numbering of the types starts at 0 with the first return value and 38324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// continues from there through the parameter list. This is useful for 39324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// "matching" types. 40324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver struct IntrinsicSignature { 41324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// RetVTs - The MVT::SimpleValueType for each return type. Note that this 42324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// list is only populated when in the context of a target .td file. When 43324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// building Intrinsics.td, this isn't available, because we don't know 44324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// the target pointer size. 45324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::vector<MVT::SimpleValueType> RetVTs; 46324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 47324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// RetTypeDefs - The records for each return type. 48324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::vector<Record*> RetTypeDefs; 49324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 50324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that 51324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// this list is only populated when in the context of a target .td file. 52324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// When building Intrinsics.td, this isn't available, because we don't 53324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// know the target pointer size. 54324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::vector<MVT::SimpleValueType> ParamVTs; 55324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 56324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// ParamTypeDefs - The records for each parameter type. 57324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::vector<Record*> ParamTypeDefs; 58324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver }; 59324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 60324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver IntrinsicSignature IS; 61324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 62324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver // Memory mod/ref behavior of this intrinsic. 63324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver enum ModRefKind { 64324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem 65324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver }; 66324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ModRefKind ModRef; 67324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 68324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// This is set to true if the intrinsic is overloaded by its argument 69324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// types. 70324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool isOverloaded; 71324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 72324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// isCommutative - True if the intrinsic is commutative. 73324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool isCommutative; 74324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 75324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// canThrow - True if the intrinsic can throw. 76324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool canThrow; 77324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 78324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// isNoDuplicate - True if the intrinsic is marked as noduplicate. 79324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool isNoDuplicate; 80324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 81324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// isNoReturn - True if the intrinsic is no-return. 82324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool isNoReturn; 83324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 84324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// isConvergent - True if the intrinsic is marked as convergent. 85324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool isConvergent; 86324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 87324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver enum ArgAttribute { 88324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver NoCapture, 89324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ReadOnly, 90324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver ReadNone 91324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver }; 92324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes; 93324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 94324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver CodeGenIntrinsic(Record *R); 95324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver }; 96324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 97324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// LoadIntrinsics - Read all of the intrinsics defined in the specified 98324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver /// .td file. 99324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC, 100324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver bool TargetOnly); 101324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver} 102324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver 103324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver#endif 104324c4644fee44b9898524c09511bd33c3f12e2dfBen Gruver