Pffft (#3780)

* Adding a dep on pffft

* Adding submodule (somehow disappeared in previous commit)

* Added WORKSPACE and modified .gitmodules

* Formatted WORKSPACE

* Fixed files referencing incorrect path

* emoved more incorrect deps
diff --git a/.gitmodules b/.gitmodules
index c486be1..45076ab 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -53,6 +53,9 @@
 [submodule "third_party/cpuinfo"]
 	path = third_party/cpuinfo
 	url = https://github.com/pytorch/cpuinfo.git
+[submodule "third_party/pffft"]
+	path = third_party/pffft
+	url = https://bitbucket.org/jpommier/pffft.git
 [submodule "third_party/llvm-bazel"]
 	path = third_party/llvm-bazel
 	url = https://github.com/google/llvm-bazel.git
diff --git a/CMakeLists.txt b/CMakeLists.txt
index e02be51..e37de7a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -405,6 +405,7 @@
 include(flatbuffer_cc_library)
 
 add_subdirectory(build_tools/third_party/flatcc EXCLUDE_FROM_ALL)
+add_subdirectory(build_tools/third_party/pffft EXCLUDE_FROM_ALL)
 add_subdirectory(build_tools/third_party/renderdoc_api EXCLUDE_FROM_ALL)
 add_subdirectory(build_tools/third_party/ruy EXCLUDE_FROM_ALL)
 
diff --git a/SUBMODULE_VERSIONS b/SUBMODULE_VERSIONS
index 1da4687..0910aa6 100644
--- a/SUBMODULE_VERSIONS
+++ b/SUBMODULE_VERSIONS
@@ -8,6 +8,7 @@
 e3f662922d8340a7fd46a4f75cad0e72163bf219 third_party/llvm-bazel
 f147f59cd377a6be68e5ca5c343eb11df8e7ee6f third_party/llvm-project
 9e970e18057e80e8af07f96d73714e395bac98d1 third_party/mlir-emitc
+74d7261be17cf659d5930d4830609406bd7553e3 third_party/pffft
 d8c7ee00a687ac369e62e2032514a93a9b413502 third_party/pybind11
 d79362c24fd70eab3196672273dbfd8f0dd6124c third_party/ruy
 a1390ed39ec77ecfb574bc6fcd5bfc5e3adbdea9 third_party/sdl2
diff --git a/WORKSPACE b/WORKSPACE
index fb6dbfe..5c0ead1 100644
--- a/WORKSPACE
+++ b/WORKSPACE
@@ -286,6 +286,13 @@
     path = "third_party/cpuinfo",
 )
 
+maybe(
+    new_local_repository,
+    name = "pffft",
+    build_file = "build_tools/third_party/pffft/BUILD.overlay",
+    path = "third_party/pffft",
+)
+
 GOOGLE_RESEARCH_COMMIT = "a5213e2c92c3e87849fe417ba42786d0324e7c75"
 
 http_archive(
diff --git a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
index 3270e79..5a23bc1 100644
--- a/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
+++ b/build_tools/bazel_to_cmake/bazel_to_cmake_targets.py
@@ -70,6 +70,7 @@
     "@com_github_dvidelabs_flatcc//:runtime": ["flatcc::runtime"],
     "@com_google_googletest//:gtest": ["gmock", "gtest"],
     "@renderdoc_api//:renderdoc_app": ["renderdoc_api::renderdoc_app"],
+    "@pffft//:pffft": ["pffft"],
     "@sdl2//:SDL2": ["SDL2-static"],
     "@com_github_pytorch_cpuinfo//:cpuinfo": ["cpuinfo"],
 }
diff --git a/build_tools/third_party/pffft/BUILD.overlay b/build_tools/third_party/pffft/BUILD.overlay
new file mode 100644
index 0000000..96306ba
--- /dev/null
+++ b/build_tools/third_party/pffft/BUILD.overlay
@@ -0,0 +1,39 @@
+# Description:
+#    PFFFT does 1D Fast Fourier Transforms, of single precision real and complex
+#    vectors. It tries do it fast, it tries to be correct, and it tries to be
+#    small.
+package(default_visibility = ["//visibility:public"])
+
+cc_library(
+    name = "pffft",
+    srcs = [
+        "pffft.c",
+    ],
+    hdrs = [
+        "pffft.h",
+    ],
+)
+
+cc_library(
+    name = "fftpack",
+    testonly = 1,
+    srcs = [
+        "fftpack.c",
+    ],
+    hdrs = [
+        "fftpack.h",
+    ],
+    visibility = ["//visibility:private"],
+)
+
+cc_binary(
+    name = "pffft_test",
+    testonly = 1,
+    srcs = [
+        "test_pffft.c",
+    ],
+    deps = [
+        ":fftpack",
+        ":pffft",
+    ],
+)
diff --git a/build_tools/third_party/pffft/CMakeLists.txt b/build_tools/third_party/pffft/CMakeLists.txt
new file mode 100644
index 0000000..9ead8fc
--- /dev/null
+++ b/build_tools/third_party/pffft/CMakeLists.txt
@@ -0,0 +1,55 @@
+# Copyright 2020 Google LLC
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+set(PFFFT_ROOT "${IREE_ROOT_DIR}/third_party/pffft/")
+
+external_cc_library(
+  PACKAGE
+    pffft
+  NAME
+    pffft
+  ROOT
+    ${PFFFT_ROOT}
+  SRCS
+    "pffft.c"
+  HDRS
+    "pffft.h"
+)
+
+external_cc_library(
+  PACKAGE
+    pffft
+  NAME
+    fftpack
+  ROOT
+    ${PFFFT_ROOT}
+  SRCS
+    "fftpack.c"
+  HDRS
+    "fftpack.h"
+)
+
+external_cc_library(
+  PACKAGE
+    pffft
+  NAME
+    pffft_test
+  ROOT
+    ${PFFFT_ROOT}
+  SRCS
+    "test_pffft.c"
+  DEPS
+    pffft::fftpack
+    pffft::pffft
+)
diff --git a/third_party/pffft b/third_party/pffft
new file mode 160000
index 0000000..74d7261
--- /dev/null
+++ b/third_party/pffft
@@ -0,0 +1 @@
+Subproject commit 74d7261be17cf659d5930d4830609406bd7553e3