Add Nanojit configuration flags (such as --sse) to lirasm. (bug 526974, r=nnethercote)
authorJacob Bramley <Jacob.Bramley@arm.com>
Tue, 24 Nov 2009 11:05:20 +0000
changeset 35358 7ca62ed84eb596b3eff273b38a78915a41fea9c2
parent 35357 91555af5f8b8ca69a2fcb592a7fe05db758e0071
child 35359 33d3a0d5f799b015d6d6e54c3c1727f0ab01f47a
push id10560
push userrsayre@mozilla.com
push dateTue, 01 Dec 2009 18:15:12 +0000
treeherdermozilla-central@e2860a4dcf0c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersnnethercote
bugs526974
milestone1.9.3a1pre
Add Nanojit configuration flags (such as --sse) to lirasm. (bug 526974, r=nnethercote)
js/src/lirasm/lirasm.cpp
--- a/js/src/lirasm/lirasm.cpp
+++ b/js/src/lirasm/lirasm.cpp
@@ -1885,17 +1885,21 @@ usageAndQuit(const string& progname)
 {
     cout <<
         "usage: " << progname << " [options] [filename]\n"
         "Options:\n"
         "  -h --help        print this message\n"
         "  -v --verbose     print LIR and assembly code\n"
         "  --execute        execute LIR\n"
         "  --random [N]     generate a random LIR block of size N (default=100)\n"
-        "  --sse            use SSE2 instructions (x86 only)\n"
+        " i386-specific options:\n"
+        "  --sse            use SSE2 instructions\n"
+        " ARM-specific options:\n"
+        "  --arch N         generate code for ARM architecture version N (default=7)\n"
+        "  --[no]vfp        enable or disable the generation of ARM VFP code (default=on)\n"
         ;
     exit(0);
 }
 
 void
 errMsgAndQuit(const string& progname, const string& msg)
 {
     cerr << progname << ": " << msg << endl;
@@ -1912,21 +1916,29 @@ struct CmdLineOptions {
 
 static void
 processCmdLine(int argc, char **argv, CmdLineOptions& opts)
 {
     opts.progname = argv[0];
     opts.verbose  = false;
     opts.execute  = false;
     opts.random   = 0;
-    bool sse      = false;
+
+    // Architecture-specific options.
+#if defined NANOJIT_IA32
+    bool            i386_sse = false;
+#elif defined NANOJIT_ARM
+    unsigned int    arm_arch = 7;
+    bool            arm_vfp = true;
+#endif
 
     for (int i = 1; i < argc; i++) {
         string arg = argv[i];
 
+        // Common flags for every architecture.
         if (arg == "-h" || arg == "--help")
             usageAndQuit(opts.progname);
         else if (arg == "-v" || arg == "--verbose")
             opts.verbose = true;
         else if (arg == "--execute")
             opts.execute = true;
         else if (arg == "--random") {
             const int defaultSize = 100;
@@ -1941,44 +1953,68 @@ processCmdLine(int argc, char **argv, Cm
                         errMsgAndQuit(opts.progname, "--random argument must be greater than zero");
                     opts.random = res;          // next arg is a number, use that for the size
                     i++;
                 } else {
                     opts.random = defaultSize;  // next arg is not a number
                 }
             }
         }
+        // Architecture-specific flags.
+#if defined NANOJIT_IA32
         else if (arg == "--sse") {
-            sse = true;
+            i386_sse = true;
         }
+#elif defined NANOJIT_ARM
+        else if ((arg == "--arch") && (i < argc-1)) {
+            char* endptr;
+            arm_arch = strtoul(argv[i+1], &endptr, 10);
+            // Check that the argument was a number.
+            if ('\0' == *endptr) {
+                if ((arm_arch < 5) || (arm_arch > 7)) {
+                    errMsgAndQuit(opts.progname, "Unsupported argument to --arm-arch.\n");
+                }
+            } else {
+                errMsgAndQuit(opts.progname, "Unrecognized argument to --arm-arch.\n");
+            }
+            i++;
+        } else if (arg == "--vfp") {
+            arm_vfp = true;
+        } else if (arg == "--novfp") {
+            arm_vfp = false;
+        }
+#endif
+        // Input file names.
         else if (arg[0] != '-') {
             if (opts.filename.empty())
                 opts.filename = arg;
             else
                 errMsgAndQuit(opts.progname, "you can only specify one filename");
         }
+        // No matching flag found, so report the error.
         else
             errMsgAndQuit(opts.progname, "bad option: " + arg);
     }
 
     if ((!opts.random && opts.filename.empty()) || (opts.random && !opts.filename.empty()))
         errMsgAndQuit(opts.progname,
                       "you must specify either a filename or --random (but not both)");
 
-#if defined NANOJIT_ARM
-    avmplus::AvmCore::config.arch = 7;
-    avmplus::AvmCore::config.vfp = true;
-#endif
-
+    // Handle the architecture-specific options.
 #if defined NANOJIT_IA32
-    avmplus::AvmCore::config.use_cmov = avmplus::AvmCore::config.sse2 = sse;
+    avmplus::AvmCore::config.use_cmov = avmplus::AvmCore::config.sse2 = i386_sse;
     avmplus::AvmCore::config.fixed_esp = true;
-#else
-    if (sse)
-        errMsgAndQuit(opts.progname, "--sse is only allowed on x86");
+#elif defined NANOJIT_ARM
+    // Note that we don't check for sensible configurations here!
+    avmplus::AvmCore::config.arch = arm_arch;
+    avmplus::AvmCore::config.vfp = arm_vfp;
+    avmplus::AvmCore::config.soft_float = !arm_vfp;
+    // This doesn't allow us to test ARMv6T2 (which also supports Thumb2), but this shouldn't
+    // really matter here.
+    avmplus::AvmCore::config.thumb2 = (arm_arch >= 7);
 #endif
 }
 
 int
 main(int argc, char **argv)
 {
     CmdLineOptions opts;
     processCmdLine(argc, argv, opts);