Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(118)

Side by Side Diff: src/IceIntrinsics.h

Issue 577353003: Add call instructions to Subzero's bitcode reader. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero.git@master
Patch Set: Fix remaining issues raised. Created 6 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceIntrinsics.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- C++ -*-===// 1 //===- subzero/src/IceIntrinsics.h - List of Ice Intrinsics -----*- C++ -*-===//
2 // 2 //
3 // The Subzero Code Generator 3 // The Subzero Code Generator
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This file declares the kinds of intrinsics supported by PNaCl. 10 // This file declares the kinds of intrinsics supported by PNaCl.
11 // 11 //
12 //===----------------------------------------------------------------------===// 12 //===----------------------------------------------------------------------===//
13 13
14 #ifndef SUBZERO_SRC_ICEINTRINSICS_H 14 #ifndef SUBZERO_SRC_ICEINTRINSICS_H
15 #define SUBZERO_SRC_ICEINTRINSICS_H 15 #define SUBZERO_SRC_ICEINTRINSICS_H
16 16
17 #include "IceDefs.h" 17 #include "IceDefs.h"
18 #include "IceTypes.h" 18 #include "IceTypes.h"
19 19
20 namespace Ice { 20 namespace Ice {
21 21
22 class InstCall;
23
22 static const size_t kMaxIntrinsicParameters = 6; 24 static const size_t kMaxIntrinsicParameters = 6;
23 25
24 class Intrinsics { 26 class Intrinsics {
25 public: 27 public:
26 Intrinsics(); 28 Intrinsics();
27 ~Intrinsics(); 29 ~Intrinsics();
28 30
29 // Some intrinsics allow overloading by type. This enum collapses all 31 // Some intrinsics allow overloading by type. This enum collapses all
30 // overloads into a single ID, but the type can still be recovered by the 32 // overloads into a single ID, but the type can still be recovered by the
31 // type of the intrinsic function call's return value and parameters. 33 // type of the intrinsic function call's return value and parameters.
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 // Basic attributes related to each intrinsic, that are relevant to 103 // Basic attributes related to each intrinsic, that are relevant to
102 // code generation. Perhaps the attributes representation can be shared 104 // code generation. Perhaps the attributes representation can be shared
103 // with general function calls, but PNaCl currently strips all 105 // with general function calls, but PNaCl currently strips all
104 // attributes from functions. 106 // attributes from functions.
105 struct IntrinsicInfo { 107 struct IntrinsicInfo {
106 enum IntrinsicID ID : 30; 108 enum IntrinsicID ID : 30;
107 enum SideEffects HasSideEffects : 1; 109 enum SideEffects HasSideEffects : 1;
108 enum ReturnsTwice ReturnsTwice : 1; 110 enum ReturnsTwice ReturnsTwice : 1;
109 }; 111 };
110 112
113 // The types of validation values for FullIntrinsicInfo.validateCall.
114 enum ValidateCallValue {
115 IsValidCall, // Valid use of instrinsic call.
116 BadReturnType, // Return type invalid for intrinsic.
117 WrongNumOfArgs, // Wrong number of arguments for intrinsic.
118 WrongCallArgType, // Argument of wrong type.
119 };
120
111 // The complete set of information about an intrinsic. 121 // The complete set of information about an intrinsic.
112 struct FullIntrinsicInfo { 122 struct FullIntrinsicInfo {
113 struct IntrinsicInfo Info; // Information that CodeGen would care about. 123 struct IntrinsicInfo Info; // Information that CodeGen would care about.
114 124
115 // Sanity check during parsing. 125 // Sanity check during parsing.
116 Type Signature[kMaxIntrinsicParameters]; 126 Type Signature[kMaxIntrinsicParameters];
117 uint8_t NumTypes; 127 uint8_t NumTypes;
128
129 // Validates that type signature of call matches intrinsic.
130 // If WrongArgumentType is returned, ArgIndex is set to corresponding
131 // argument index.
132 ValidateCallValue validateCall(const Ice::InstCall *Call,
133 SizeT &ArgIndex) const;
134
135 // Returns the return type of the intrinsic.
136 Type getReturnType() const {
137 assert(NumTypes > 1);
138 return Signature[0];
139 }
140
141 // Returns number of arguments expected.
142 SizeT getNumArgs() const {
143 assert(NumTypes > 1);
144 return NumTypes - 1;
145 }
146
147 // Returns type of Index-th argument.
148 Type getArgType(SizeT Index) const;
118 }; 149 };
119 150
120 // Find the information about a given intrinsic, based on function name. 151 // Find the information about a given intrinsic, based on function name.
121 // The function name is expected to have the common "llvm." prefix 152 // The function name is expected to have the common "llvm." prefix
122 // stripped. If found, returns a reference to a FullIntrinsicInfo entry 153 // stripped. If found, returns a reference to a FullIntrinsicInfo entry
123 // (valid for the lifetime of the map). Otherwise returns null. 154 // (valid for the lifetime of the map). Otherwise returns null.
124 const FullIntrinsicInfo *find(const IceString &Name) const; 155 const FullIntrinsicInfo *find(const IceString &Name) const;
125 156
126 private: 157 private:
127 // TODO(jvoung): May want to switch to something like LLVM's StringMap. 158 // TODO(jvoung): May want to switch to something like LLVM's StringMap.
128 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap; 159 typedef std::map<IceString, FullIntrinsicInfo> IntrinsicMap;
129 IntrinsicMap map; 160 IntrinsicMap map;
130 161
131 Intrinsics(const Intrinsics &) LLVM_DELETED_FUNCTION; 162 Intrinsics(const Intrinsics &) LLVM_DELETED_FUNCTION;
132 Intrinsics &operator=(const Intrinsics &) LLVM_DELETED_FUNCTION; 163 Intrinsics &operator=(const Intrinsics &) LLVM_DELETED_FUNCTION;
133 }; 164 };
134 165
135 } // end of namespace Ice 166 } // end of namespace Ice
136 167
137 #endif // SUBZERO_SRC_ICEINTRINSICS_H 168 #endif // SUBZERO_SRC_ICEINTRINSICS_H
OLDNEW
« no previous file with comments | « src/IceInst.cpp ('k') | src/IceIntrinsics.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698