CodeGenIntrinsics.h revision 223017
1191983Sweongyo//===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===// 2191983Sweongyo// 3191983Sweongyo// The LLVM Compiler Infrastructure 4191983Sweongyo// 5191983Sweongyo// This file is distributed under the University of Illinois Open Source 6191983Sweongyo// License. See LICENSE.TXT for details. 7191983Sweongyo// 8191983Sweongyo//===----------------------------------------------------------------------===// 9191983Sweongyo// 10191983Sweongyo// This file defines a wrapper class for the 'Intrinsic' TableGen class. 11191983Sweongyo// 12191983Sweongyo//===----------------------------------------------------------------------===// 13191983Sweongyo 14191983Sweongyo#ifndef CODEGEN_INTRINSIC_H 15191983Sweongyo#define CODEGEN_INTRINSIC_H 16191983Sweongyo 17191983Sweongyo#include <string> 18191983Sweongyo#include <vector> 19191983Sweongyo#include "llvm/CodeGen/ValueTypes.h" 20191983Sweongyo 21191983Sweongyonamespace llvm { 22191983Sweongyo class Record; 23191983Sweongyo class RecordKeeper; 24191983Sweongyo class CodeGenTarget; 25191983Sweongyo 26191983Sweongyo struct CodeGenIntrinsic { 27191983Sweongyo Record *TheDef; // The actual record defining this intrinsic. 28191983Sweongyo std::string Name; // The name of the LLVM function "llvm.bswap.i32" 29191983Sweongyo std::string EnumName; // The name of the enum "bswap_i32" 30191983Sweongyo std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "". 31191983Sweongyo std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics. 32191983Sweongyo 33191983Sweongyo /// IntrinsicSignature - This structure holds the return values and 34191983Sweongyo /// parameter values of an intrinsic. If the number of return values is > 1, 35191983Sweongyo /// then the intrinsic implicitly returns a first-class aggregate. The 36191983Sweongyo /// numbering of the types starts at 0 with the first return value and 37191983Sweongyo /// continues from there through the parameter list. This is useful for 38191983Sweongyo /// "matching" types. 39191983Sweongyo struct IntrinsicSignature { 40191983Sweongyo /// RetVTs - The MVT::SimpleValueType for each return type. Note that this 41191983Sweongyo /// list is only populated when in the context of a target .td file. When 42191983Sweongyo /// building Intrinsics.td, this isn't available, because we don't know 43191983Sweongyo /// the target pointer size. 44191983Sweongyo std::vector<MVT::SimpleValueType> RetVTs; 45191983Sweongyo 46191983Sweongyo /// RetTypeDefs - The records for each return type. 47191983Sweongyo std::vector<Record*> RetTypeDefs; 48191983Sweongyo 49191983Sweongyo /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that 50191983Sweongyo /// this list is only populated when in the context of a target .td file. 51194677Sthompsa /// When building Intrinsics.td, this isn't available, because we don't 52191983Sweongyo /// know the target pointer size. 53191983Sweongyo std::vector<MVT::SimpleValueType> ParamVTs; 54191983Sweongyo 55191983Sweongyo /// ParamTypeDefs - The records for each parameter type. 56191983Sweongyo std::vector<Record*> ParamTypeDefs; 57191983Sweongyo }; 58191983Sweongyo 59191983Sweongyo IntrinsicSignature IS; 60191983Sweongyo 61191983Sweongyo // Memory mod/ref behavior of this intrinsic. 62191983Sweongyo enum { 63191983Sweongyo NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem 64191983Sweongyo } ModRef; 65191983Sweongyo 66191983Sweongyo /// This is set to true if the intrinsic is overloaded by its argument 67191983Sweongyo /// types. 68191983Sweongyo bool isOverloaded; 69191983Sweongyo 70191983Sweongyo /// isCommutative - True if the intrinsic is commutative. 71191983Sweongyo bool isCommutative; 72191983Sweongyo 73191983Sweongyo /// canThrow - True if the intrinsic can throw. 74191983Sweongyo bool canThrow; 75191983Sweongyo 76191983Sweongyo enum ArgAttribute { 77191983Sweongyo NoCapture 78191983Sweongyo }; 79191983Sweongyo std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes; 80191983Sweongyo 81191983Sweongyo CodeGenIntrinsic(Record *R); 82191983Sweongyo }; 83191983Sweongyo 84191983Sweongyo /// LoadIntrinsics - Read all of the intrinsics defined in the specified 85191983Sweongyo /// .td file. 86191983Sweongyo std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC, 87191983Sweongyo bool TargetOnly); 88191983Sweongyo} 89191983Sweongyo 90191983Sweongyo#endif 91191983Sweongyo