pw_toolchain: Add toolchain support for Cortex M7

Change-Id: Iafb63b7e15bc4183923d91af4c839ead9a85e876
Reviewed-on: https://pigweed-review.googlesource.com/c/pigweed/pigweed/+/13786
Commit-Queue: Armando Montanez <amontanez@google.com>
Reviewed-by: Armando Montanez <amontanez@google.com>
diff --git a/pw_toolchain/arm_gcc/BUILD.gn b/pw_toolchain/arm_gcc/BUILD.gn
index 781047b..1fafdf9 100644
--- a/pw_toolchain/arm_gcc/BUILD.gn
+++ b/pw_toolchain/arm_gcc/BUILD.gn
@@ -64,6 +64,12 @@
   ldflags = cflags
 }
 
+config("cortex_m7") {
+  cflags = [ "-mcpu=cortex-m7" ]
+  asmflags = cflags
+  ldflags = cflags
+}
+
 config("cortex_software_fpu") {
   cflags = [ "-mfloat-abi=soft" ]
   asmflags = cflags
@@ -79,3 +85,13 @@
   defines = [ "PW_ARMV7M_ENABLE_FPU=1" ]
   ldflags = cflags
 }
+
+config("cortex_hardware_fpu_v5") {
+  cflags = [
+    "-mfloat-abi=hard",
+    "-mfpu=fpv5-d16",
+  ]
+  asmflags = cflags
+  defines = [ "PW_ARMV7M_ENABLE_FPU=1" ]
+  ldflags = cflags
+}
diff --git a/pw_toolchain/arm_gcc/toolchains.gni b/pw_toolchain/arm_gcc/toolchains.gni
index d1b890b..bf7dc25 100644
--- a/pw_toolchain/arm_gcc/toolchains.gni
+++ b/pw_toolchain/arm_gcc/toolchains.gni
@@ -47,6 +47,18 @@
   "$dir_pw_toolchain/arm_gcc:cortex_hardware_fpu",
 ]
 
+_cortex_m7 = [
+  "$dir_pw_toolchain/arm_gcc:cortex_common",
+  "$dir_pw_toolchain/arm_gcc:cortex_m7",
+  "$dir_pw_toolchain/arm_gcc:cortex_software_fpu",
+]
+
+_cortex_m7f = [
+  "$dir_pw_toolchain/arm_gcc:cortex_common",
+  "$dir_pw_toolchain/arm_gcc:cortex_m7",
+  "$dir_pw_toolchain/arm_gcc:cortex_hardware_fpu_v5",
+]
+
 # Describes ARM GCC toolchains for specific targets.
 pw_toolchain_arm_gcc = {
   cortex_m3_debug = {
@@ -121,6 +133,54 @@
           _arm_gcc + _cortex_m4f + [ "$dir_pw_build:optimize_size" ]
     }
   }
+  cortex_m7_debug = {
+    name = "arm_gcc_cortex_m7_debug"
+    forward_variables_from(arm_gcc_toolchain_tools, "*")
+    defaults = {
+      default_configs =
+          _arm_gcc + _cortex_m7 + [ "$dir_pw_build:optimize_debugging" ]
+    }
+  }
+  cortex_m7_speed_optimized = {
+    name = "arm_gcc_cortex_m7_speed_optimized"
+    forward_variables_from(arm_gcc_toolchain_tools, "*")
+    defaults = {
+      default_configs =
+          _arm_gcc + _cortex_m7 + [ "$dir_pw_build:optimize_speed" ]
+    }
+  }
+  cortex_m7_size_optimized = {
+    name = "arm_gcc_cortex_m7_size_optimized"
+    forward_variables_from(arm_gcc_toolchain_tools, "*")
+    defaults = {
+      default_configs =
+          _arm_gcc + _cortex_m7 + [ "$dir_pw_build:optimize_size" ]
+    }
+  }
+  cortex_m7f_debug = {
+    name = "arm_gcc_cortex_m7f_debug"
+    forward_variables_from(arm_gcc_toolchain_tools, "*")
+    defaults = {
+      default_configs =
+          _arm_gcc + _cortex_m7f + [ "$dir_pw_build:optimize_debugging" ]
+    }
+  }
+  cortex_m7f_speed_optimized = {
+    name = "arm_gcc_cortex_m7f_speed_optimized"
+    forward_variables_from(arm_gcc_toolchain_tools, "*")
+    defaults = {
+      default_configs =
+          _arm_gcc + _cortex_m7f + [ "$dir_pw_build:optimize_speed" ]
+    }
+  }
+  cortex_m7f_size_optimized = {
+    name = "arm_gcc_cortex_m7f_size_optimized"
+    forward_variables_from(arm_gcc_toolchain_tools, "*")
+    defaults = {
+      default_configs =
+          _arm_gcc + _cortex_m7f + [ "$dir_pw_build:optimize_size" ]
+    }
+  }
 }
 
 # This list just contains the members of the above scope for convenience to make
@@ -136,4 +196,10 @@
   pw_toolchain_arm_gcc.cortex_m4f_debug,
   pw_toolchain_arm_gcc.cortex_m4f_speed_optimized,
   pw_toolchain_arm_gcc.cortex_m4f_size_optimized,
+  pw_toolchain_arm_gcc.cortex_m7_debug,
+  pw_toolchain_arm_gcc.cortex_m7_speed_optimized,
+  pw_toolchain_arm_gcc.cortex_m7_size_optimized,
+  pw_toolchain_arm_gcc.cortex_m7f_debug,
+  pw_toolchain_arm_gcc.cortex_m7f_speed_optimized,
+  pw_toolchain_arm_gcc.cortex_m7f_size_optimized,
 ]