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

Unified Diff: lib/Analysis/NaCl/PNaClABITypeChecker.cpp

Issue 221693002: PNaCl: Add support for GCC/LLVM vector extensions (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Address dschuff's comments. Created 6 years, 8 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
Index: lib/Analysis/NaCl/PNaClABITypeChecker.cpp
diff --git a/lib/Analysis/NaCl/PNaClABITypeChecker.cpp b/lib/Analysis/NaCl/PNaClABITypeChecker.cpp
index 8749abcaa6f5d2c2c9256ff062ead93275c166d2..bf4a6997b3863c02f637dd523fbdb0590a9b555c 100644
--- a/lib/Analysis/NaCl/PNaClABITypeChecker.cpp
+++ b/lib/Analysis/NaCl/PNaClABITypeChecker.cpp
@@ -21,7 +21,7 @@
using namespace llvm;
bool PNaClABITypeChecker::isValidParamType(const Type *Ty) {
- if (!isValidScalarType(Ty))
+ if (!(isValidScalarType(Ty) || isValidVectorType(Ty)))
return false;
if (const IntegerType *IntTy = dyn_cast<IntegerType>(Ty)) {
// PNaCl requires function arguments and return values to be 32
@@ -62,3 +62,28 @@ bool PNaClABITypeChecker::isValidScalarType(const Type *Ty) {
return false;
}
}
+
+// TODO(jfb) Handle 64-bit int and double, and 2xi1.
+bool PNaClABITypeChecker::isValidVectorType(const Type *Ty) {
+ if (!Ty->isVectorTy())
+ return false;
+ unsigned Elems = Ty->getVectorNumElements();
+ const Type *VTy = Ty->getVectorElementType();
+
+ switch (VTy->getTypeID()) {
+ case Type::IntegerTyID: {
+ unsigned Width = cast<const IntegerType>(VTy)->getBitWidth();
+ switch (Width) {
+ case 1: return Elems == 4 || Elems == 8 || Elems == 16;
+ case 8: return Elems == 16;
+ case 16: return Elems == 8;
+ case 32: return Elems == 4;
+ default: return false;
+ }
+ }
+ case Type::FloatTyID:
+ return Elems == 4;
+ default:
+ return false;
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698