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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/NaCl/PNaClABI/intrinsics.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
diff --git a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
index 44c027fba4690762eb1facec317d022db28bbf95..084ddbeb9ff3f7093793688a21934adfd9fc9dac 100644
--- a/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
+++ b/lib/Analysis/NaCl/PNaClABIVerifyModule.cpp
@@ -122,6 +122,23 @@ void PNaClABIVerifyModule::CheckGlobalValueCommon(const GlobalValue *GV) {
}
}
+static bool IntTypeAcceptable(unsigned width,
+ const ArrayRef<unsigned>& AcceptableSizes) {
+ 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.
+ if (AcceptableSizes[i] == width)
+ return true;
+ return false;
+}
+
+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
+ const ArrayRef<unsigned>& AcceptableSizes) {
+ FunctionType* FT = F->getFunctionType();
+ if (FT->getNumParams() != 1)
+ return false;
+ return IntTypeAcceptable(FT->getParamType(0)->getIntegerBitWidth(),
+ AcceptableSizes);
+}
+
bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F,
unsigned ID) {
// Keep 3 categories of intrinsics for now.
@@ -135,6 +152,10 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F,
// Disallow by default.
default: return false;
// (1) Always allowed.
+ 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.
+ unsigned accepted_sizes[] = { 16, 32, 64 };
+ return FunctionHasIntArg1(F, accepted_sizes);
+ }
case Intrinsic::invariant_end:
case Intrinsic::invariant_start:
case Intrinsic::lifetime_end:
@@ -179,7 +200,6 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F,
case Intrinsic::dbg_declare:
case Intrinsic::dbg_value:
return PNaClABIAllowDevIntrinsics || PNaClABIAllowDebugMetadata;
- case Intrinsic::bswap: // Support via compiler_rt if arch doesn't have it?
case Intrinsic::cos: // Rounding not defined: support with fast-math?
case Intrinsic::ctlz: // Support via compiler_rt if arch doesn't have it?
case Intrinsic::ctpop: // Support via compiler_rt if arch doesn't have it?
@@ -187,7 +207,9 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F,
case Intrinsic::exp: // Rounding not defined: support with fast-math?
case Intrinsic::exp2: // Rounding not defined: support with fast-math?
case Intrinsic::expect: // From __builtin_expect.
- case Intrinsic::flt_rounds:
+ case Intrinsic::flt_rounds: // For FLT_ROUNDS macro from float.h.
+ // We do not have fesetround() in newlib, can we return a
+ // consistent rounding mode though?
case Intrinsic::log: // Rounding not defined: support with fast-math?
case Intrinsic::log2: // Rounding not defined: support with fast-math?
case Intrinsic::log10: // Rounding not defined: support with fast-math?
@@ -196,9 +218,9 @@ bool PNaClABIVerifyModule::IsWhitelistedIntrinsic(const Function* F,
case Intrinsic::powi: // Rounding not defined: support with fast-math?
case Intrinsic::prefetch: // Could ignore if target doesn't support?
case Intrinsic::sin: // Rounding not defined: support with fast-math?
- case Intrinsic::sqrt:
+ case Intrinsic::sqrt: // Rounding is defined, but setting errno up to libm.
case Intrinsic::stackrestore: // Used to support C99 VLAs.
- case Intrinsic::stacksave:
+ case Intrinsic::stacksave: // Used to support C99 VLAs.
// the *_with_overflow return struct types, so we'll need to fix these.
case Intrinsic::sadd_with_overflow: // Introduced by -ftrapv
case Intrinsic::ssub_with_overflow:
« 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