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

Side by Side Diff: lib/Analysis/NaCl/PNaClABIVerifyModule.cpp

Issue 14914011: Promote bswap i16, i32, and i64 to be allowed llvm intrinsics. (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Created 7 years, 7 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 | « no previous file | test/NaCl/PNaClABI/intrinsics.ll » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- PNaClABIVerifyModule.cpp - Verify PNaCl ABI rules --------===// 1 //===- PNaClABIVerifyModule.cpp - Verify PNaCl ABI rules --------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
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 // Verify module-level PNaCl ABI requirements (specifically those that do not 10 // Verify module-level PNaCl ABI requirements (specifically those that do not
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 Reporter->addError() << GVTypeName << GV->getName() 115 Reporter->addError() << GVTypeName << GV->getName()
116 << " has disallowed linkage type: " 116 << " has disallowed linkage type: "
117 << linkageName(GV->getLinkage()) << "\n"; 117 << linkageName(GV->getLinkage()) << "\n";
118 } 118 }
119 if (GV->hasSection()) { 119 if (GV->hasSection()) {
120 Reporter->addError() << GVTypeName << GV->getName() << 120 Reporter->addError() << GVTypeName << GV->getName() <<
121 " has disallowed \"section\" attribute\n"; 121 " has disallowed \"section\" attribute\n";
122 } 122 }
123 } 123 }
124 124
125 static bool IntTypeAcceptable(unsigned width,
126 const ArrayRef<unsigned>& AcceptableSizes) {
127 for (unsigned i = 0; i < AcceptableSizes.size(); ++i)
eliben 2013/05/15 23:34:54 Would it be cleaner to iterate over it (it has ite
jvoung (off chromium) 2013/05/16 16:45:00 Done.
128 if (AcceptableSizes[i] == width)
129 return true;
130 return false;
131 }
132
133 static bool FunctionHasIntArg1(const Function* F,
eliben 2013/05/15 23:34:54 The name is not entirely clear... also you may be
jvoung (off chromium) 2013/05/16 16:45:00 Well, I assume I'll be checking parameter types fo
134 const ArrayRef<unsigned>& AcceptableSizes) {
135 FunctionType* FT = F->getFunctionType();
136 if (FT->getNumParams() != 1)
137 return false;
138 return IntTypeAcceptable(FT->getParamType(0)->getIntegerBitWidth(),
139 AcceptableSizes);
140 }
141
125 bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F, 142 bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F,
126 unsigned ID) { 143 unsigned ID) {
127 // Keep 3 categories of intrinsics for now. 144 // Keep 3 categories of intrinsics for now.
128 // (1) Allowed always 145 // (1) Allowed always
129 // (2) Never allowed 146 // (2) Never allowed
130 // (3) "Dev" intrinsics, which may or may not be allowed. 147 // (3) "Dev" intrinsics, which may or may not be allowed.
131 // "Dev" intrinsics are controlled by the PNaClABIAllowDevIntrinsics flag. 148 // "Dev" intrinsics are controlled by the PNaClABIAllowDevIntrinsics flag.
132 // Please keep these sorted or grouped in a sensible way, within 149 // Please keep these sorted or grouped in a sensible way, within
133 // each category. 150 // each category.
134 switch(ID) { 151 switch(ID) {
135 // Disallow by default. 152 // Disallow by default.
136 default: return false; 153 default: return false;
137 // (1) Always allowed. 154 // (1) Always allowed.
155 case Intrinsic::bswap: {
eliben 2013/05/15 23:34:54 I think this would be clearer in a method - isWhit
jvoung (off chromium) 2013/05/16 16:45:00 Done.
156 unsigned accepted_sizes[] = { 16, 32, 64 };
157 return FunctionHasIntArg1(F, accepted_sizes);
158 }
138 case Intrinsic::invariant_end: 159 case Intrinsic::invariant_end:
139 case Intrinsic::invariant_start: 160 case Intrinsic::invariant_start:
140 case Intrinsic::lifetime_end: 161 case Intrinsic::lifetime_end:
141 case Intrinsic::lifetime_start: 162 case Intrinsic::lifetime_start:
142 case Intrinsic::memcpy: 163 case Intrinsic::memcpy:
143 case Intrinsic::memmove: 164 case Intrinsic::memmove:
144 case Intrinsic::memset: 165 case Intrinsic::memset:
145 case Intrinsic::nacl_read_tp: 166 case Intrinsic::nacl_read_tp:
146 case Intrinsic::nacl_setjmp: 167 case Intrinsic::nacl_setjmp:
147 case Intrinsic::nacl_longjmp: 168 case Intrinsic::nacl_longjmp:
(...skipping 24 matching lines...) Expand all
172 // Var-args handling is done w/out intrinsics. 193 // Var-args handling is done w/out intrinsics.
173 case Intrinsic::vacopy: 194 case Intrinsic::vacopy:
174 case Intrinsic::vaend: 195 case Intrinsic::vaend:
175 case Intrinsic::vastart: 196 case Intrinsic::vastart:
176 return false; 197 return false;
177 198
178 // (3) Dev intrinsics. 199 // (3) Dev intrinsics.
179 case Intrinsic::dbg_declare: 200 case Intrinsic::dbg_declare:
180 case Intrinsic::dbg_value: 201 case Intrinsic::dbg_value:
181 return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata; 202 return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata;
182 case Intrinsic::bswap: // Support via compiler_rt if arch doesn't have it?
183 case Intrinsic::cos: // Rounding not defined: support with fast-math? 203 case Intrinsic::cos: // Rounding not defined: support with fast-math?
184 case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it? 204 case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it?
185 case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it? 205 case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it?
186 case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it? 206 case Intrinsic::cttz: // Support via compiler_rt if arch doesn't have it?
187 case Intrinsic::exp: // Rounding not defined: support with fast-math? 207 case Intrinsic::exp: // Rounding not defined: support with fast-math?
188 case Intrinsic::exp2: // Rounding not defined: support with fast-math? 208 case Intrinsic::exp2: // Rounding not defined: support with fast-math?
189 case Intrinsic::expect: // From __builtin_expect. 209 case Intrinsic::expect: // From __builtin_expect.
190 case Intrinsic::flt_rounds: 210 case Intrinsic::flt_rounds: // For FLT_ROUNDS macro from float.h.
211 // We do not have fesetround() in newlib, can we return a
212 // consistent rounding mode though?
191 case Intrinsic::log: // Rounding not defined: support with fast-math? 213 case Intrinsic::log: // Rounding not defined: support with fast-math?
192 case Intrinsic::log2: // Rounding not defined: support with fast-math? 214 case Intrinsic::log2: // Rounding not defined: support with fast-math?
193 case Intrinsic::log10: // Rounding not defined: support with fast-math? 215 case Intrinsic::log10: // Rounding not defined: support with fast-math?
194 case Intrinsic::nacl_target_arch: // Used by translator self-build. 216 case Intrinsic::nacl_target_arch: // Used by translator self-build.
195 case Intrinsic::pow: // Rounding is supposed to be the same as libm. 217 case Intrinsic::pow: // Rounding is supposed to be the same as libm.
196 case Intrinsic::powi: // Rounding not defined: support with fast-math? 218 case Intrinsic::powi: // Rounding not defined: support with fast-math?
197 case Intrinsic::prefetch: // Could ignore if target doesn't support? 219 case Intrinsic::prefetch: // Could ignore if target doesn't support?
198 case Intrinsic::sin: // Rounding not defined: support with fast-math? 220 case Intrinsic::sin: // Rounding not defined: support with fast-math?
199 case Intrinsic::sqrt: 221 case Intrinsic::sqrt: // Rounding is defined, but setting errno up to libm.
200 case Intrinsic::stackrestore: // Used to support C99 VLAs. 222 case Intrinsic::stackrestore: // Used to support C99 VLAs.
201 case Intrinsic::stacksave: 223 case Intrinsic::stacksave: // Used to support C99 VLAs.
202 // the *_with_overflow return struct types, so we'll need to fix these. 224 // the *_with_overflow return struct types, so we'll need to fix these.
203 case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv 225 case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv
204 case Intrinsic::ssub_with_overflow: 226 case Intrinsic::ssub_with_overflow:
205 case Intrinsic::uadd_with_overflow: 227 case Intrinsic::uadd_with_overflow:
206 case Intrinsic::usub_with_overflow: 228 case Intrinsic::usub_with_overflow:
207 case Intrinsic::smul_with_overflow: 229 case Intrinsic::smul_with_overflow:
208 case Intrinsic::umul_with_overflow: // Introduced by c++ new[x * y]. 230 case Intrinsic::umul_with_overflow: // Introduced by c++ new[x * y].
209 return PNaClABIAllowDevIntrinsics; 231 return PNaClABIAllowDevIntrinsics;
210 } 232 }
211 } 233 }
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 } 341 }
320 342
321 char PNaClABIVerifyModule::ID = 0; 343 char PNaClABIVerifyModule::ID = 0;
322 INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module", 344 INITIALIZE_PASS(PNaClABIVerifyModule, "verify-pnaclabi-module",
323 "Verify module for PNaCl", false, true) 345 "Verify module for PNaCl", false, true)
324 346
325 ModulePass *llvm::createPNaClABIVerifyModulePass( 347 ModulePass *llvm::createPNaClABIVerifyModulePass(
326 PNaClABIErrorReporter *Reporter) { 348 PNaClABIErrorReporter *Reporter) {
327 return new PNaClABIVerifyModule(Reporter); 349 return new PNaClABIVerifyModule(Reporter);
328 } 350 }
OLDNEW
« no previous file with comments | « no previous file | test/NaCl/PNaClABI/intrinsics.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698