Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 1 | //===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===// |
| 2 | // |
| 3 | // The LLVM Compiler Infrastructure |
| 4 | // |
Chris Lattner | 8adcd9f | 2007-12-29 20:37:13 +0000 | [diff] [blame] | 5 | // This file is distributed under the University of Illinois Open Source |
| 6 | // License. See LICENSE.TXT for details. |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | // |
| 10 | // This file defines a wrapper class for the 'Intrinsic' TableGen class. |
| 11 | // |
| 12 | //===----------------------------------------------------------------------===// |
| 13 | |
Benjamin Kramer | a7c40ef | 2014-08-13 16:26:38 +0000 | [diff] [blame] | 14 | #ifndef LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H |
| 15 | #define LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 16 | |
Patrik Hagglund | 8d09a6c | 2014-03-15 09:11:41 +0000 | [diff] [blame] | 17 | #include "llvm/CodeGen/MachineValueType.h" |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 18 | #include <string> |
| 19 | #include <vector> |
| 20 | |
| 21 | namespace llvm { |
| 22 | class Record; |
| 23 | class RecordKeeper; |
Chris Lattner | c92f688 | 2006-03-27 22:48:18 +0000 | [diff] [blame] | 24 | class CodeGenTarget; |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 25 | |
| 26 | struct CodeGenIntrinsic { |
Reid Spencer | e67d0c2 | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 27 | Record *TheDef; // The actual record defining this intrinsic. |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 28 | std::string Name; // The name of the LLVM function "llvm.bswap.i32" |
| 29 | std::string EnumName; // The name of the enum "bswap_i32" |
Chris Lattner | fea17a9 | 2006-03-13 23:08:44 +0000 | [diff] [blame] | 30 | std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "". |
Saleem Abdulrasool | 4e63fc4 | 2014-07-04 18:42:25 +0000 | [diff] [blame] | 31 | std::string MSBuiltinName; // Name of the corresponding MS builtin, or "". |
Chris Lattner | 402a573 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 32 | std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics. |
Duncan Sands | 13237ac | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 33 | |
Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 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 |
Jim Grosbach | 975c1cb | 2009-03-26 16:17:51 +0000 | [diff] [blame] | 38 | /// continues from there through the parameter list. This is useful for |
Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 39 | /// "matching" types. |
| 40 | struct IntrinsicSignature { |
Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 41 | /// RetVTs - The MVT::SimpleValueType for each return type. Note that this |
Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 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. |
Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 45 | std::vector<MVT::SimpleValueType> RetVTs; |
Duncan Sands | 13237ac | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 46 | |
Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 47 | /// RetTypeDefs - The records for each return type. |
| 48 | std::vector<Record*> RetTypeDefs; |
| 49 | |
Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 50 | /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that |
Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 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. |
Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 54 | std::vector<MVT::SimpleValueType> ParamVTs; |
Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 55 | |
| 56 | /// ParamTypeDefs - The records for each parameter type. |
| 57 | std::vector<Record*> ParamTypeDefs; |
| 58 | }; |
| 59 | |
| 60 | IntrinsicSignature IS; |
| 61 | |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 62 | // Memory mod/ref behavior of this intrinsic. |
Igor Laevsky | 30143ae | 2015-08-13 17:40:04 +0000 | [diff] [blame] | 63 | enum ModRefKind { |
Dan Gohman | ddb2d65 | 2010-08-05 23:36:21 +0000 | [diff] [blame] | 64 | NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem |
Igor Laevsky | 30143ae | 2015-08-13 17:40:04 +0000 | [diff] [blame] | 65 | }; |
| 66 | ModRefKind ModRef; |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 67 | |
Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 68 | /// This is set to true if the intrinsic is overloaded by its argument |
| 69 | /// types. |
Reid Spencer | e67d0c2 | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 70 | bool isOverloaded; |
| 71 | |
Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 72 | /// isCommutative - True if the intrinsic is commutative. |
Evan Cheng | 49bad4c | 2008-06-16 20:29:38 +0000 | [diff] [blame] | 73 | bool isCommutative; |
John McCall | 375dcc9 | 2011-05-28 06:31:34 +0000 | [diff] [blame] | 74 | |
| 75 | /// canThrow - True if the intrinsic can throw. |
| 76 | bool canThrow; |
Chris Lattner | ff9e08b | 2012-05-27 23:20:41 +0000 | [diff] [blame] | 77 | |
Eli Bendersky | 2281ef9 | 2014-03-18 23:51:07 +0000 | [diff] [blame] | 78 | /// isNoDuplicate - True if the intrinsic is marked as noduplicate. |
| 79 | bool isNoDuplicate; |
| 80 | |
Chris Lattner | ff9e08b | 2012-05-27 23:20:41 +0000 | [diff] [blame] | 81 | /// isNoReturn - True if the intrinsic is no-return. |
| 82 | bool isNoReturn; |
| 83 | |
Owen Anderson | 85fa7d5 | 2015-05-26 23:48:40 +0000 | [diff] [blame] | 84 | /// isConvergent - True if the intrinsic is marked as convergent. |
| 85 | bool isConvergent; |
| 86 | |
Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 87 | enum ArgAttribute { |
Nick Lewycky | c2ec072 | 2013-07-06 00:29:58 +0000 | [diff] [blame] | 88 | NoCapture, |
| 89 | ReadOnly, |
| 90 | ReadNone |
Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 91 | }; |
| 92 | std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes; |
Evan Cheng | 49bad4c | 2008-06-16 20:29:38 +0000 | [diff] [blame] | 93 | |
Dan Gohman | fc4ad7de | 2008-04-03 00:02:49 +0000 | [diff] [blame] | 94 | CodeGenIntrinsic(Record *R); |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 95 | }; |
| 96 | |
| 97 | /// LoadIntrinsics - Read all of the intrinsics defined in the specified |
| 98 | /// .td file. |
Dale Johannesen | b842d52 | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 99 | std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC, |
| 100 | bool TargetOnly); |
Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 101 | } |
| 102 | |
| 103 | #endif |