blob: 7bdb7e1bc537cc7f621f6ac8b4ebcabc9dc8aca9 [file] [log] [blame]
Chris Lattnerc313d0b2006-03-03 02:32:46 +00001//===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner8adcd9f2007-12-29 20:37:13 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnerc313d0b2006-03-03 02:32:46 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This file defines a wrapper class for the 'Intrinsic' TableGen class.
11//
12//===----------------------------------------------------------------------===//
13
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000014#ifndef LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H
15#define LLVM_UTILS_TABLEGEN_CODEGENINTRINSICS_H
Chris Lattnerc313d0b2006-03-03 02:32:46 +000016
Patrik Hagglund8d09a6c2014-03-15 09:11:41 +000017#include "llvm/CodeGen/MachineValueType.h"
Chris Lattnerc313d0b2006-03-03 02:32:46 +000018#include <string>
19#include <vector>
20
21namespace llvm {
22 class Record;
23 class RecordKeeper;
Chris Lattnerc92f6882006-03-27 22:48:18 +000024 class CodeGenTarget;
Chris Lattnerc313d0b2006-03-03 02:32:46 +000025
26 struct CodeGenIntrinsic {
Reid Spencere67d0c22007-04-01 07:20:02 +000027 Record *TheDef; // The actual record defining this intrinsic.
Chris Lattnerc313d0b2006-03-03 02:32:46 +000028 std::string Name; // The name of the LLVM function "llvm.bswap.i32"
29 std::string EnumName; // The name of the enum "bswap_i32"
Chris Lattnerfea17a92006-03-13 23:08:44 +000030 std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "".
Saleem Abdulrasool4e63fc42014-07-04 18:42:25 +000031 std::string MSBuiltinName; // Name of the corresponding MS builtin, or "".
Chris Lattner402a5732006-03-15 01:33:26 +000032 std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics.
Duncan Sands13237ac2008-06-06 12:08:01 +000033
Bill Wendling91821472008-11-13 09:08:33 +000034 /// 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 Grosbach975c1cb2009-03-26 16:17:51 +000038 /// continues from there through the parameter list. This is useful for
Bill Wendling91821472008-11-13 09:08:33 +000039 /// "matching" types.
40 struct IntrinsicSignature {
Owen Anderson9f944592009-08-11 20:47:22 +000041 /// RetVTs - The MVT::SimpleValueType for each return type. Note that this
Bill Wendling91821472008-11-13 09:08:33 +000042 /// 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 Anderson9f944592009-08-11 20:47:22 +000045 std::vector<MVT::SimpleValueType> RetVTs;
Duncan Sands13237ac2008-06-06 12:08:01 +000046
Bill Wendling91821472008-11-13 09:08:33 +000047 /// RetTypeDefs - The records for each return type.
48 std::vector<Record*> RetTypeDefs;
49
Owen Anderson9f944592009-08-11 20:47:22 +000050 /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that
Bill Wendling91821472008-11-13 09:08:33 +000051 /// 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 Anderson9f944592009-08-11 20:47:22 +000054 std::vector<MVT::SimpleValueType> ParamVTs;
Bill Wendling91821472008-11-13 09:08:33 +000055
56 /// ParamTypeDefs - The records for each parameter type.
57 std::vector<Record*> ParamTypeDefs;
58 };
59
60 IntrinsicSignature IS;
61
Chris Lattnerc313d0b2006-03-03 02:32:46 +000062 // Memory mod/ref behavior of this intrinsic.
Igor Laevsky30143ae2015-08-13 17:40:04 +000063 enum ModRefKind {
Dan Gohmanddb2d652010-08-05 23:36:21 +000064 NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem
Igor Laevsky30143ae2015-08-13 17:40:04 +000065 };
66 ModRefKind ModRef;
Chris Lattnerc313d0b2006-03-03 02:32:46 +000067
Chris Lattner9a3113a2009-01-12 01:12:03 +000068 /// This is set to true if the intrinsic is overloaded by its argument
69 /// types.
Reid Spencere67d0c22007-04-01 07:20:02 +000070 bool isOverloaded;
71
Chris Lattner9a3113a2009-01-12 01:12:03 +000072 /// isCommutative - True if the intrinsic is commutative.
Evan Cheng49bad4c2008-06-16 20:29:38 +000073 bool isCommutative;
John McCall375dcc92011-05-28 06:31:34 +000074
75 /// canThrow - True if the intrinsic can throw.
76 bool canThrow;
Chris Lattnerff9e08b2012-05-27 23:20:41 +000077
Eli Bendersky2281ef92014-03-18 23:51:07 +000078 /// isNoDuplicate - True if the intrinsic is marked as noduplicate.
79 bool isNoDuplicate;
80
Chris Lattnerff9e08b2012-05-27 23:20:41 +000081 /// isNoReturn - True if the intrinsic is no-return.
82 bool isNoReturn;
83
Owen Anderson85fa7d52015-05-26 23:48:40 +000084 /// isConvergent - True if the intrinsic is marked as convergent.
85 bool isConvergent;
86
Chris Lattner9a3113a2009-01-12 01:12:03 +000087 enum ArgAttribute {
Nick Lewyckyc2ec0722013-07-06 00:29:58 +000088 NoCapture,
89 ReadOnly,
90 ReadNone
Chris Lattner9a3113a2009-01-12 01:12:03 +000091 };
92 std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes;
Evan Cheng49bad4c2008-06-16 20:29:38 +000093
Dan Gohmanfc4ad7de2008-04-03 00:02:49 +000094 CodeGenIntrinsic(Record *R);
Chris Lattnerc313d0b2006-03-03 02:32:46 +000095 };
96
97 /// LoadIntrinsics - Read all of the intrinsics defined in the specified
98 /// .td file.
Dale Johannesenb842d522009-02-05 01:49:45 +000099 std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC,
100 bool TargetOnly);
Chris Lattnerc313d0b2006-03-03 02:32:46 +0000101}
102
103#endif