| 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 |  | 
|  | 14 | #ifndef CODEGEN_INTRINSIC_H | 
|  | 15 | #define CODEGEN_INTRINSIC_H | 
|  | 16 |  | 
|  | 17 | #include <string> | 
|  | 18 | #include <vector> | 
| Chris Lattner | 2c58141 | 2006-03-24 19:49:31 +0000 | [diff] [blame] | 19 | #include "llvm/CodeGen/ValueTypes.h" | 
| Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 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 "". | 
| Chris Lattner | 402a573 | 2006-03-15 01:33:26 +0000 | [diff] [blame] | 31 | std::string TargetPrefix;  // Target prefix, e.g. "ppc" for t-s intrinsics. | 
| Duncan Sands | 13237ac | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 32 |  | 
| Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 33 | /// IntrinsicSignature - This structure holds the return values and | 
|  | 34 | /// parameter values of an intrinsic. If the number of return values is > 1, | 
|  | 35 | /// then the intrinsic implicitly returns a first-class aggregate. The | 
|  | 36 | /// 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] | 37 | /// continues from there through the parameter list. This is useful for | 
| Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 38 | /// "matching" types. | 
|  | 39 | struct IntrinsicSignature { | 
| Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 40 | /// RetVTs - The MVT::SimpleValueType for each return type. Note that this | 
| Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 41 | /// list is only populated when in the context of a target .td file. When | 
|  | 42 | /// building Intrinsics.td, this isn't available, because we don't know | 
|  | 43 | /// the target pointer size. | 
| Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 44 | std::vector<MVT::SimpleValueType> RetVTs; | 
| Duncan Sands | 13237ac | 2008-06-06 12:08:01 +0000 | [diff] [blame] | 45 |  | 
| Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 46 | /// RetTypeDefs - The records for each return type. | 
|  | 47 | std::vector<Record*> RetTypeDefs; | 
|  | 48 |  | 
| Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 49 | /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that | 
| Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 50 | /// this list is only populated when in the context of a target .td file. | 
|  | 51 | /// When building Intrinsics.td, this isn't available, because we don't | 
|  | 52 | /// know the target pointer size. | 
| Owen Anderson | 9f94459 | 2009-08-11 20:47:22 +0000 | [diff] [blame] | 53 | std::vector<MVT::SimpleValueType> ParamVTs; | 
| Bill Wendling | 9182147 | 2008-11-13 09:08:33 +0000 | [diff] [blame] | 54 |  | 
|  | 55 | /// ParamTypeDefs - The records for each parameter type. | 
|  | 56 | std::vector<Record*> ParamTypeDefs; | 
|  | 57 | }; | 
|  | 58 |  | 
|  | 59 | IntrinsicSignature IS; | 
|  | 60 |  | 
| Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 61 | // Memory mod/ref behavior of this intrinsic. | 
|  | 62 | enum { | 
| Dan Gohman | ddb2d65 | 2010-08-05 23:36:21 +0000 | [diff] [blame] | 63 | NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem | 
| Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 64 | } ModRef; | 
|  | 65 |  | 
| Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 66 | /// This is set to true if the intrinsic is overloaded by its argument | 
|  | 67 | /// types. | 
| Reid Spencer | e67d0c2 | 2007-04-01 07:20:02 +0000 | [diff] [blame] | 68 | bool isOverloaded; | 
|  | 69 |  | 
| Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 70 | /// isCommutative - True if the intrinsic is commutative. | 
| Evan Cheng | 49bad4c | 2008-06-16 20:29:38 +0000 | [diff] [blame] | 71 | bool isCommutative; | 
| Chris Lattner | 9a3113a | 2009-01-12 01:12:03 +0000 | [diff] [blame] | 72 |  | 
|  | 73 | enum ArgAttribute { | 
|  | 74 | NoCapture | 
|  | 75 | }; | 
|  | 76 | std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes; | 
| Evan Cheng | 49bad4c | 2008-06-16 20:29:38 +0000 | [diff] [blame] | 77 |  | 
| Dan Gohman | fc4ad7de | 2008-04-03 00:02:49 +0000 | [diff] [blame] | 78 | CodeGenIntrinsic(Record *R); | 
| Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 79 | }; | 
|  | 80 |  | 
|  | 81 | /// LoadIntrinsics - Read all of the intrinsics defined in the specified | 
|  | 82 | /// .td file. | 
| Dale Johannesen | b842d52 | 2009-02-05 01:49:45 +0000 | [diff] [blame] | 83 | std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC, | 
|  | 84 | bool TargetOnly); | 
| Chris Lattner | c313d0b | 2006-03-03 02:32:46 +0000 | [diff] [blame] | 85 | } | 
|  | 86 |  | 
|  | 87 | #endif |