[MIPS] Add support for mips32r1 arch variant

Change-Id: I37dfecd8c92f3f34c117432956d169f4b191c849
Reviewed-on: https://swiftshader-review.googlesource.com/c/23248
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Milko Leporis <milko.leporis@mips.com>
diff --git a/BUILD.gn b/BUILD.gn
index 027adfd..56c78ce 100644
--- a/BUILD.gn
+++ b/BUILD.gn
@@ -14,6 +14,7 @@
 
 import("//build/config/c++/c++.gni")
 import("//build/config/compiler/compiler.gni")
+import("//build/config/mips.gni")
 
 config("swiftshader_config") {
   defines = []
@@ -99,11 +100,19 @@
     } else if (target_cpu == "mipsel" && current_cpu == target_cpu) {
       cflags += [
         "-march=mipsel",
-        "-mcpu=mips32r2",
         "-fPIC",
         "-mhard-float",
         "-mfp32",
       ]
+      if (mips_arch_variant == "r1") {
+        cflags += [
+          "-mcpu=mips32",
+        ]
+      } else {
+        cflags += [
+          "-mcpu=mips32r2",
+        ]
+      }
     } else if (target_cpu == "mips64el" && current_cpu == target_cpu) {
       cflags += [
         "-march=mips64el",
@@ -119,8 +128,16 @@
       if (target_cpu == "mipsel") {
         ldflags += [
           "-Wl,--hash-style=sysv",
-          "-mips32r2",
         ]
+        if (mips_arch_variant == "r1") {
+          ldflags += [
+            "-mips32",
+          ]
+        } else {
+          ldflags += [
+            "-mips32r2",
+          ]
+        }
       } else if (target_cpu == "mips64el") {
         ldflags += [
           "-Wl,--hash-style=sysv",