blob: 3208c0d628d96bafc83a7a224a226c19f0373a6f [file] [log] [blame]
Chris Lattner9e493cf2006-03-03 02:32:46 +00001//===- CodeGenIntrinsic.h - Intrinsic Class Wrapper ------------*- C++ -*--===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner30609102007-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 Lattner9e493cf2006-03-03 02:32:46 +00007//
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 Lattner43fbbc32006-03-24 19:49:31 +000019#include "llvm/CodeGen/ValueTypes.h"
Chris Lattner9e493cf2006-03-03 02:32:46 +000020
21namespace llvm {
22 class Record;
23 class RecordKeeper;
Chris Lattner8850a1b2006-03-27 22:48:18 +000024 class CodeGenTarget;
Chris Lattner9e493cf2006-03-03 02:32:46 +000025
26 struct CodeGenIntrinsic {
Reid Spencerc4de3de2007-04-01 07:20:02 +000027 Record *TheDef; // The actual record defining this intrinsic.
Chris Lattner9e493cf2006-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 Lattner022f64f2006-03-13 23:08:44 +000030 std::string GCCBuiltinName;// Name of the corresponding GCC builtin, or "".
Chris Lattner3f8b8912006-03-15 01:33:26 +000031 std::string TargetPrefix; // Target prefix, e.g. "ppc" for t-s intrinsics.
Duncan Sands83ec4b62008-06-06 12:08:01 +000032
Bill Wendlingcdcc3e62008-11-13 09:08:33 +000033 /// 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 Grosbachda4231f2009-03-26 16:17:51 +000037 /// continues from there through the parameter list. This is useful for
Bill Wendlingcdcc3e62008-11-13 09:08:33 +000038 /// "matching" types.
39 struct IntrinsicSignature {
Owen Anderson825b72b2009-08-11 20:47:22 +000040 /// RetVTs - The MVT::SimpleValueType for each return type. Note that this
Bill Wendlingcdcc3e62008-11-13 09:08:33 +000041 /// 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 Anderson825b72b2009-08-11 20:47:22 +000044 std::vector<MVT::SimpleValueType> RetVTs;
Duncan Sands83ec4b62008-06-06 12:08:01 +000045
Bill Wendlingcdcc3e62008-11-13 09:08:33 +000046 /// RetTypeDefs - The records for each return type.
47 std::vector<Record*> RetTypeDefs;
48
Owen Anderson825b72b2009-08-11 20:47:22 +000049 /// ParamVTs - The MVT::SimpleValueType for each parameter type. Note that
Bill Wendlingcdcc3e62008-11-13 09:08:33 +000050 /// 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 Anderson825b72b2009-08-11 20:47:22 +000053 std::vector<MVT::SimpleValueType> ParamVTs;
Bill Wendlingcdcc3e62008-11-13 09:08:33 +000054
55 /// ParamTypeDefs - The records for each parameter type.
56 std::vector<Record*> ParamTypeDefs;
57 };
58
59 IntrinsicSignature IS;
60
Chris Lattner9e493cf2006-03-03 02:32:46 +000061 // Memory mod/ref behavior of this intrinsic.
62 enum {
Dan Gohman7365c092010-08-05 23:36:21 +000063 NoMem, ReadArgMem, ReadMem, ReadWriteArgMem, ReadWriteMem
Chris Lattner9e493cf2006-03-03 02:32:46 +000064 } ModRef;
65
Chris Lattnera62c3022009-01-12 01:12:03 +000066 /// This is set to true if the intrinsic is overloaded by its argument
67 /// types.
Reid Spencerc4de3de2007-04-01 07:20:02 +000068 bool isOverloaded;
69
Chris Lattnera62c3022009-01-12 01:12:03 +000070 /// isCommutative - True if the intrinsic is commutative.
Evan Cheng6bd95672008-06-16 20:29:38 +000071 bool isCommutative;
Chris Lattnera62c3022009-01-12 01:12:03 +000072
73 enum ArgAttribute {
74 NoCapture
75 };
76 std::vector<std::pair<unsigned, ArgAttribute> > ArgumentAttributes;
Evan Cheng6bd95672008-06-16 20:29:38 +000077
Dan Gohmanee4fa192008-04-03 00:02:49 +000078 CodeGenIntrinsic(Record *R);
Chris Lattner9e493cf2006-03-03 02:32:46 +000079 };
80
81 /// LoadIntrinsics - Read all of the intrinsics defined in the specified
82 /// .td file.
Dale Johannesen49de9822009-02-05 01:49:45 +000083 std::vector<CodeGenIntrinsic> LoadIntrinsics(const RecordKeeper &RC,
84 bool TargetOnly);
Chris Lattner9e493cf2006-03-03 02:32:46 +000085}
86
87#endif