[RS4GC] Add an assert which fails if there is a (yet unsupported) addrspacecast.
[oota-llvm.git] / utils / PerfectShuffle / PerfectShuffle.cpp
index 98f8f4cc0cab8e58048cff0a18486c45e38fc437..5c142a5f54e16f6541031ec2cc3e9ce633289e47 100644 (file)
 //
 //===----------------------------------------------------------------------===//
 
-#include <iostream>
-#include <iomanip>
-#include <vector>
 #include <cassert>
 #include <cstdlib>
+#include <iomanip>
+#include <iostream>
+#include <vector>
 struct Operator;
 
 // Masks are 4-nibble hex numbers.  Values 0-7 in any nibble means that it takes
@@ -85,8 +85,8 @@ static void PrintMask(unsigned i, std::ostream &OS) {
 
 /// ShuffleVal - This represents a shufflevector operation.
 struct ShuffleVal {
-  unsigned Cost;  // Number of instrs used to generate this value.
   Operator *Op;   // The Operation used to generate this value.
+  unsigned Cost;  // Number of instrs used to generate this value.
   unsigned short Arg0, Arg1;  // Input operands for this value.
 
   ShuffleVal() : Cost(1000000) {}
@@ -102,14 +102,14 @@ static std::vector<Operator*> TheOperators;
 
 /// Operator - This is a vector operation that is available for use.
 struct Operator {
+  const char *Name;
   unsigned short ShuffleMask;
   unsigned short OpNum;
-  const char *Name;
   unsigned Cost;
 
   Operator(unsigned short shufflemask, const char *name, unsigned opnum,
            unsigned cost = 1)
-    : ShuffleMask(shufflemask), OpNum(opnum), Name(name), Cost(cost) {
+    :  Name(name), ShuffleMask(shufflemask), OpNum(opnum),Cost(cost) {
     TheOperators.push_back(this);
   }
   ~Operator() {
@@ -219,10 +219,10 @@ static void EvaluateOps(unsigned short Elt, unsigned short Vals[],
 int main() {
   // Seed the table with accesses to the LHS and RHS.
   ShufTab[0x0123].Cost = 0;
-  ShufTab[0x0123].Op = 0;
+  ShufTab[0x0123].Op = nullptr;
   ShufTab[0x0123].Arg0 = 0x0123;
   ShufTab[0x4567].Cost = 0;
-  ShufTab[0x4567].Op = 0;
+  ShufTab[0x4567].Op = nullptr;
   ShufTab[0x4567].Arg0 = 0x4567;
 
   // Seed the first-level of shuffles, shuffles whose inputs are the input to