Android: Add Android.bp files for a host build.

This makes it possible to build swiftshader for the host.

The target build also works but it has been disabled.

Change-Id: I8aecf931f4ebf72c06d4e3423e2eafea6bfa7f6c
Reviewed-on: https://swiftshader-review.googlesource.com/17988
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Tested-by: Alistair Strachan <astrachan@google.com>
diff --git a/Android.bp b/Android.bp
new file mode 100644
index 0000000..f8c596f
--- /dev/null
+++ b/Android.bp
@@ -0,0 +1,108 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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
+//
+//      http://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.
+//
+
+cc_defaults {
+    name: "swiftshader_common",
+
+    gnu_extensions: false,
+
+    cflags: [
+        "-Xclang", "-fuse-init-array",
+        "-fno-operator-names",
+        "-msse2",
+        "-Werror",
+        "-Wwrite-strings",
+    ],
+
+    cppflags: [
+        "-Woverloaded-virtual",
+    ],
+
+    target: {
+        host: {
+            cppflags: [
+                "-fno-rtti",
+                "-fno-exceptions",
+            ],
+            compile_multilib: "64",
+        },
+
+        // We don't need Darwin host-side builds
+        darwin: {
+            enabled: false,
+        },
+    },
+}
+
+cc_defaults {
+    name: "swiftshader_common_release",
+
+    defaults: [ "swiftshader_common" ],
+
+    cflags: [
+        "-Os",
+        "-fomit-frame-pointer",
+        "-ffunction-sections",
+        "-fdata-sections",
+    ],
+}
+
+cc_defaults {
+    name: "swiftshader_common_debug",
+
+    defaults: [ "swiftshader_common" ],
+
+    cflags: [
+        "-O0",
+        "-g",
+        "-UNDEBUG",
+    ],
+}
+
+cc_defaults {
+    name: "swiftshader_subzero",
+
+    cflags: [
+        "-DALLOW_DUMP=0",
+        "-DALLOW_TIMERS=0",
+        "-DALLOW_LLVM_CL=0",
+        "-DALLOW_LLVM_IR=0",
+        "-DALLOW_LLVM_IR_AS_INPUT=0",
+        "-DALLOW_MINIMAL_BUILD=0",
+        "-DALLOW_WASM=0",
+        "-DICE_THREAD_LOCAL_HACK=1",
+    ],
+}
+
+cc_library_headers {
+    name: "swiftshader_platform_headers",
+    host_supported: true,
+    export_include_dirs: ["include"],
+}
+
+cc_library_headers {
+    name: "swiftshader_host_headers",
+    device_supported: false,
+    host_supported: true,
+    export_include_dirs: ["include/Android"],
+}
+
+subdirs = [
+    "src",
+    "third_party/llvm-subzero",
+    "third_party/LLVM",
+    "third_party/subzero",
+]
diff --git a/src/Android.bp b/src/Android.bp
new file mode 100644
index 0000000..4c19ab3
--- /dev/null
+++ b/src/Android.bp
@@ -0,0 +1,520 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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
+//
+//      http://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.
+//
+
+cc_defaults {
+    name: "libswiftshader",
+
+    device_supported: false,
+    host_supported: true,
+    vendor: true,
+
+    defaults: [ "swiftshader_common" ],
+
+    cflags: [
+        "-D_GNU_SOURCE",
+        "-D__STDC_LIMIT_MACROS",
+        "-D__STDC_CONSTANT_MACROS",
+        "-D__STDC_FORMAT_MACROS",
+        "-DHAVE_GRALLOC1",
+        "-DNO_SANITIZE_FUNCTION=",
+        // FIXME: Use <android/api-level.h> instead?
+        "-DANDROID_PLATFORM_SDK_VERSION=10000",
+        "-Wno-unused-parameter",
+        "-Wno-unused-local-typedef",
+    ],
+
+    cppflags: [
+        "-Wno-sign-promo",
+        "-Wno-non-virtual-dtor",
+    ],
+
+    local_include_dirs: [ "OpenGL" ],
+
+    target: {
+        android: {
+            relative_install_path: "hw",
+            header_libs: [
+                "swiftshader_platform_headers",
+            ],
+            shared_libs: [
+                "libnativewindow",
+                "libhardware",
+                "libcutils",
+                "libsync",
+                "liblog",
+            ],
+        },
+
+        host: {
+            header_libs: [
+                "swiftshader_host_headers",
+                "swiftshader_platform_headers",
+            ],
+
+            // Pretend to build for Android
+            cflags: [ "-D__ANDROID__", "-DANDROID_HOST_BUILD" ],
+
+            allow_undefined_symbols: true,
+            host_ldlibs: ["-ldl"],
+        },
+    },
+}
+
+cc_defaults {
+    name: "libswiftshader_release",
+
+    defaults: [ "libswiftshader" ],
+
+    cflags: [
+        "-fomit-frame-pointer",
+        "-ffunction-sections",
+        "-fdata-sections",
+        "-DANGLE_DISABLE_TRACE",
+    ],
+}
+
+cc_defaults {
+    name: "libswiftshader_debug",
+
+    defaults: [ "libswiftshader" ],
+
+    cflags: [
+        "-UNDEBUG",
+        "-g",
+        "-O0",
+        "-DDEFAULT_THREAD_COUNT=1",
+    ],
+}
+
+// Common libraries
+
+cc_defaults {
+    name: "libswiftshader_common_defaults",
+
+    cflags: [
+        "-DLOG_TAG=\"swiftshader\"",
+    ],
+
+    srcs: [
+        "Common/CPUID.cpp",
+        "Common/Configurator.cpp",
+        "Common/DebugAndroid.cpp",
+        "Common/GrallocAndroid.cpp",
+        "Common/Half.cpp",
+        "Common/Math.cpp",
+        "Common/Memory.cpp",
+        "Common/Resource.cpp",
+        "Common/Socket.cpp",
+        "Common/Thread.cpp",
+        "Common/Timer.cpp",
+        "Main/Config.cpp",
+        "Main/FrameBuffer.cpp",
+        "Main/FrameBufferAndroid.cpp",
+        "Main/SwiftConfig.cpp",
+        "Renderer/Blitter.cpp",
+        "Renderer/Clipper.cpp",
+        "Renderer/Color.cpp",
+        "Renderer/Context.cpp",
+        "Renderer/ETC_Decoder.cpp",
+        "Renderer/Matrix.cpp",
+        "Renderer/PixelProcessor.cpp",
+        "Renderer/Plane.cpp",
+        "Renderer/Point.cpp",
+        "Renderer/QuadRasterizer.cpp",
+        "Renderer/Renderer.cpp",
+        "Renderer/Sampler.cpp",
+        "Renderer/SetupProcessor.cpp",
+        "Renderer/Surface.cpp",
+        "Renderer/TextureStage.cpp",
+        "Renderer/Vector.cpp",
+        "Renderer/VertexProcessor.cpp",
+        "Shader/Constants.cpp",
+        "Shader/PixelPipeline.cpp",
+        "Shader/PixelProgram.cpp",
+        "Shader/PixelRoutine.cpp",
+        "Shader/PixelShader.cpp",
+        "Shader/SamplerCore.cpp",
+        "Shader/SetupRoutine.cpp",
+        "Shader/Shader.cpp",
+        "Shader/ShaderCore.cpp",
+        "Shader/VertexPipeline.cpp",
+        "Shader/VertexProgram.cpp",
+        "Shader/VertexRoutine.cpp",
+        "Shader/VertexShader.cpp",
+        "OpenGL/common/Image.cpp",
+        "OpenGL/common/Object.cpp",
+        "OpenGL/common/MatrixStack.cpp",
+    ],
+
+    target: {
+        host: {
+            exclude_srcs: [ "Common/DebugAndroid.cpp" ],
+            srcs: [ "Common/Debug.cpp" ],
+        },
+    },
+}
+
+cc_defaults {
+    name: "libswiftshader_llvm_defaults",
+
+    defaults: [ "libswiftshader_common_defaults" ],
+
+    srcs: [
+        "Reactor/LLVMReactor.cpp",
+        "Reactor/Routine.cpp",
+        "Reactor/LLVMRoutine.cpp",
+        "Reactor/LLVMRoutineManager.cpp",
+    ],
+
+    static_libs: [
+        "libLLVM_swiftshader",
+    ],
+}
+
+cc_defaults {
+    name: "libswiftshader_subzero_defaults",
+
+    defaults: [ "libswiftshader_common_defaults", "swiftshader_subzero" ],
+
+    srcs: [
+        "Reactor/SubzeroReactor.cpp",
+        "Reactor/Routine.cpp",
+        "Reactor/Optimizer.cpp",
+    ],
+
+    static_libs: [
+        "libLLVMSupport_subzero",
+        "libsubzero",
+    ],
+}
+
+cc_defaults {
+    name: "libswiftshader_common",
+
+    defaults: [ "libswiftshader_release", "libswiftshader_common_defaults" ],
+}
+
+cc_defaults {
+    name: "libswiftshader_common_debug",
+
+    srcs: [ "OpenGL/common/debug.cpp" ],
+
+    defaults: [ "libswiftshader_debug", "libswiftshader_common_defaults" ],
+}
+
+cc_library_static {
+    name: "libswiftshader_llvm",
+
+    defaults: [ "libswiftshader_common", "libswiftshader_llvm_defaults" ],
+}
+
+cc_library_static {
+    name: "libswiftshader_llvm_debug",
+
+    defaults: [ "libswiftshader_common_debug", "libswiftshader_llvm_defaults" ],
+}
+
+cc_library_static {
+    name: "libswiftshader_subzero",
+
+    defaults: [ "libswiftshader_common", "libswiftshader_subzero_defaults" ],
+}
+
+cc_library_static {
+    name: "libswiftshader_subzero_debug",
+
+    defaults: [ "libswiftshader_common_debug", "libswiftshader_subzero_defaults" ],
+}
+
+// compiler libraries
+
+cc_defaults {
+    name: "libswiftshader_compiler_defaults",
+
+    defaults: [ "libswiftshader" ],
+
+    cflags: [
+        "-DLOG_TAG=\"swiftshader_compiler\"",
+    ],
+
+    srcs: [
+        "OpenGL/compiler/preprocessor/DiagnosticsBase.cpp",
+        "OpenGL/compiler/preprocessor/DirectiveHandlerBase.cpp",
+        "OpenGL/compiler/preprocessor/DirectiveParser.cpp",
+        "OpenGL/compiler/preprocessor/ExpressionParser.cpp",
+        "OpenGL/compiler/preprocessor/Input.cpp",
+        "OpenGL/compiler/preprocessor/Lexer.cpp",
+        "OpenGL/compiler/preprocessor/Macro.cpp",
+        "OpenGL/compiler/preprocessor/MacroExpander.cpp",
+        "OpenGL/compiler/preprocessor/Preprocessor.cpp",
+        "OpenGL/compiler/preprocessor/Token.cpp",
+        "OpenGL/compiler/preprocessor/Tokenizer.cpp",
+        "OpenGL/compiler/AnalyzeCallDepth.cpp",
+        "OpenGL/compiler/Compiler.cpp",
+        "OpenGL/compiler/debug.cpp",
+        "OpenGL/compiler/Diagnostics.cpp",
+        "OpenGL/compiler/DirectiveHandler.cpp",
+        "OpenGL/compiler/glslang_lex.cpp",
+        "OpenGL/compiler/glslang_tab.cpp",
+        "OpenGL/compiler/InfoSink.cpp",
+        "OpenGL/compiler/Initialize.cpp",
+        "OpenGL/compiler/InitializeParseContext.cpp",
+        "OpenGL/compiler/IntermTraverse.cpp",
+        "OpenGL/compiler/Intermediate.cpp",
+        "OpenGL/compiler/intermOut.cpp",
+        "OpenGL/compiler/ossource_posix.cpp",
+        "OpenGL/compiler/OutputASM.cpp",
+        "OpenGL/compiler/parseConst.cpp",
+        "OpenGL/compiler/ParseHelper.cpp",
+        "OpenGL/compiler/PoolAlloc.cpp",
+        "OpenGL/compiler/SymbolTable.cpp",
+        "OpenGL/compiler/TranslatorASM.cpp",
+        "OpenGL/compiler/util.cpp",
+        "OpenGL/compiler/ValidateLimitations.cpp",
+        "OpenGL/compiler/ValidateSwitch.cpp",
+    ],
+}
+
+cc_library_static {
+    name: "libswiftshader_compiler",
+
+    defaults: [ "libswiftshader_release", "libswiftshader_compiler_defaults" ],
+}
+
+cc_library_static {
+    name: "libswiftshader_compiler_debug",
+
+    defaults: [ "libswiftshader_debug", "libswiftshader_compiler_defaults" ],
+}
+
+// libEGL libraries
+
+cc_defaults {
+    name: "swiftshader_client_libraries_subzero_or_llvm",
+
+    defaults: [ "libswiftshader_release" ],
+
+    target: {
+        android_arm: {
+            static_libs: [
+                "libswiftshader_subzero",
+                "libsubzero",
+                "libLLVMSupport_subzero",
+            ],
+        },
+
+        android: {
+            static_libs: [
+                "libswiftshader_llvm",
+                "libLLVM_swiftshader",
+            ],
+        },
+
+        host: {
+            static_libs: [
+                "libswiftshader_llvm",
+                "libLLVM_swiftshader",
+            ],
+        },
+    },
+}
+
+cc_defaults {
+    name: "swiftshader_client_libraries_subzero_or_llvm_debug",
+
+    defaults: [ "libswiftshader_debug" ],
+
+    target: {
+        android_arm: {
+            static_libs: [
+                "libswiftshader_subzero_debug",
+                "libsubzero",
+                "libLLVMSupport_subzero",
+            ],
+        },
+
+        android: {
+            static_libs: [
+                "libswiftshader_llvm_debug",
+                "libLLVM_swiftshader",
+            ],
+        },
+
+        host: {
+            static_libs: [
+                "libswiftshader_llvm_debug",
+                "libLLVM_swiftshader",
+            ],
+        },
+    },
+}
+
+cc_defaults {
+    name: "libEGL_swiftshader_defaults",
+
+    defaults: [ "libswiftshader" ],
+
+    cflags: [
+        "-DLOG_TAG=\"libEGL_swiftshader\"",
+        "-DEGLAPI=",
+        "-DEGL_EGLEXT_PROTOTYPES",
+        "-Wno-format",
+    ],
+
+    srcs: [
+       "OpenGL/libEGL/Config.cpp",
+       "OpenGL/libEGL/Display.cpp",
+       "OpenGL/libEGL/Surface.cpp",
+       "OpenGL/libEGL/libEGL.cpp",
+       "OpenGL/libEGL/main.cpp",
+    ],
+
+    version_script: "OpenGL/libEGL/libEGL.lds",
+}
+
+cc_library_shared {
+    name: "libEGL_swiftshader",
+
+    defaults: [
+        "libEGL_swiftshader_defaults",
+        "swiftshader_client_libraries_subzero_or_llvm",
+    ],
+}
+
+cc_library_shared {
+    name: "libEGL_swiftshader_debug",
+
+    defaults: [
+        "libEGL_swiftshader_defaults",
+        "swiftshader_client_libraries_subzero_or_llvm_debug",
+    ],
+}
+
+// libGLESv1_CM libraries
+
+cc_defaults {
+    name: "libGLESv1_CM_swiftshader_defaults",
+
+    defaults: [ "libswiftshader" ],
+
+    cflags: [
+        "-DLOG_TAG=\"libGLES_CM_swiftshader\"",
+        "-DEGLAPI=",
+        "-DGL_API=",
+        "-DGL_APICALL=",
+        "-DGL_GLEXT_PROTOTYPES",
+        "-Wno-format",
+    ],
+
+    srcs: [
+        "OpenGL/libGLES_CM/Buffer.cpp",
+        "OpenGL/libGLES_CM/Context.cpp",
+        "OpenGL/libGLES_CM/Device.cpp",
+        "OpenGL/libGLES_CM/Framebuffer.cpp",
+        "OpenGL/libGLES_CM/IndexDataManager.cpp",
+        "OpenGL/libGLES_CM/libGLES_CM.cpp",
+        "OpenGL/libGLES_CM/main.cpp",
+        "OpenGL/libGLES_CM/Renderbuffer.cpp",
+        "OpenGL/libGLES_CM/ResourceManager.cpp",
+        "OpenGL/libGLES_CM/Texture.cpp",
+        "OpenGL/libGLES_CM/utilities.cpp",
+        "OpenGL/libGLES_CM/VertexDataManager.cpp",
+    ],
+
+    version_script: "OpenGL/libGLES_CM/libGLES_CM.lds",
+}
+
+cc_library_shared {
+    name: "libGLESv1_CM_swiftshader",
+
+    defaults: [
+        "libGLESv1_CM_swiftshader_defaults",
+        "swiftshader_client_libraries_subzero_or_llvm",
+    ],
+}
+
+cc_library_shared {
+    name: "libGLESv1_CM_swiftshader_debug",
+
+    defaults: [
+        "libGLESv1_CM_swiftshader_defaults",
+        "swiftshader_client_libraries_subzero_or_llvm_debug",
+    ],
+}
+
+// libGLESv2 libraries
+
+cc_defaults {
+    name: "libGLESv2_swiftshader_defaults",
+
+    defaults: [ "libswiftshader" ],
+
+    cflags: [
+        "-DLOG_TAG=\"libGLESv2_swiftshader\"",
+        "-DEGLAPI=",
+        "-DGL_API=",
+        "-DGL_APICALL=",
+        "-DGL_GLEXT_PROTOTYPES",
+        "-Wno-format",
+    ],
+
+    srcs: [
+        "OpenGL/libGLESv2/Buffer.cpp",
+        "OpenGL/libGLESv2/Context.cpp",
+        "OpenGL/libGLESv2/Device.cpp",
+        "OpenGL/libGLESv2/Fence.cpp",
+        "OpenGL/libGLESv2/Framebuffer.cpp",
+        "OpenGL/libGLESv2/IndexDataManager.cpp",
+        "OpenGL/libGLESv2/libGLESv2.cpp",
+        "OpenGL/libGLESv2/libGLESv3.cpp",
+        "OpenGL/libGLESv2/main.cpp",
+        "OpenGL/libGLESv2/entry_points.cpp",
+        "OpenGL/libGLESv2/Program.cpp",
+        "OpenGL/libGLESv2/Query.cpp",
+        "OpenGL/libGLESv2/Renderbuffer.cpp",
+        "OpenGL/libGLESv2/ResourceManager.cpp",
+        "OpenGL/libGLESv2/Shader.cpp",
+        "OpenGL/libGLESv2/Texture.cpp",
+        "OpenGL/libGLESv2/TransformFeedback.cpp",
+        "OpenGL/libGLESv2/utilities.cpp",
+        "OpenGL/libGLESv2/VertexArray.cpp",
+        "OpenGL/libGLESv2/VertexDataManager.cpp",
+    ],
+
+    version_script: "OpenGL/libGLESv2/libGLESv2.lds",
+}
+
+cc_library_shared {
+    name: "libGLESv2_swiftshader",
+
+    defaults: [
+        "libGLESv2_swiftshader_defaults",
+        "swiftshader_client_libraries_subzero_or_llvm",
+    ],
+
+    static_libs: [ "libswiftshader_compiler" ],
+}
+
+cc_library_shared {
+    name: "libGLESv2_swiftshader_debug",
+
+    defaults: [
+        "libGLESv2_swiftshader_defaults",
+        "swiftshader_client_libraries_subzero_or_llvm_debug",
+    ],
+
+    static_libs: [ "libswiftshader_compiler_debug" ],
+}
diff --git a/third_party/LLVM/Android.bp b/third_party/LLVM/Android.bp
new file mode 100644
index 0000000..93be07d
--- /dev/null
+++ b/third_party/LLVM/Android.bp
@@ -0,0 +1,454 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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
+//
+//      http://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.
+//
+
+// No ARM, MIPS support because there are no generated files checked in
+// for these architectures.
+
+libLLVM_swiftshader_x86_srcs = [
+    "lib/Target/X86/InstPrinter/X86ATTInstPrinter.cpp",
+    "lib/Target/X86/InstPrinter/X86InstComments.cpp",
+    "lib/Target/X86/InstPrinter/X86IntelInstPrinter.cpp",
+    "lib/Target/X86/MCTargetDesc/X86AsmBackend.cpp",
+    "lib/Target/X86/MCTargetDesc/X86MachObjectWriter.cpp",
+    "lib/Target/X86/MCTargetDesc/X86MCAsmInfo.cpp",
+    "lib/Target/X86/MCTargetDesc/X86MCCodeEmitter.cpp",
+    "lib/Target/X86/MCTargetDesc/X86MCTargetDesc.cpp",
+    "lib/Target/X86/TargetInfo/X86TargetInfo.cpp",
+    "lib/Target/X86/Utils/X86ShuffleDecode.cpp",
+    "lib/Target/X86/X86CodeEmitter.cpp",
+    "lib/Target/X86/X86ELFWriterInfo.cpp",
+    "lib/Target/X86/X86FastISel.cpp",
+    "lib/Target/X86/X86FloatingPoint.cpp",
+    "lib/Target/X86/X86FrameLowering.cpp",
+    "lib/Target/X86/X86InstrInfo.cpp",
+    "lib/Target/X86/X86ISelDAGToDAG.cpp",
+    "lib/Target/X86/X86ISelLowering.cpp",
+    "lib/Target/X86/X86JITInfo.cpp",
+    "lib/Target/X86/X86RegisterInfo.cpp",
+    "lib/Target/X86/X86SelectionDAGInfo.cpp",
+    "lib/Target/X86/X86Subtarget.cpp",
+    "lib/Target/X86/X86TargetMachine.cpp",
+    "lib/Target/X86/X86TargetObjectFile.cpp",
+    "lib/Target/X86/X86VZeroUpper.cpp",
+]
+
+cc_library_static {
+    name: "libLLVM_swiftshader",
+
+    defaults: [ "swiftshader_common_release" ],
+
+    device_supported: false,
+    host_supported: true,
+
+    cflags: [
+        "-D_GNU_SOURCE",
+        "-D__STDC_LIMIT_MACROS",
+        "-D__STDC_CONSTANT_MACROS",
+        "-D__STDC_FORMAT_MACROS",
+        "-DLOG_TAG=\"libLLVM_swiftshader\"",
+        "-Wno-unused-result",
+        "-Wno-unused-function",
+        "-Wno-unused-variable",
+        "-Wno-unused-parameter",
+        "-Wno-unused-local-typedef",
+        "-Wno-unused-private-field",
+        "-Wno-unneeded-internal-declaration",
+    ],
+
+    cppflags: [
+        "-Wno-sign-promo",
+        "-Wno-undefined-var-template",
+    ],
+
+    srcs: [
+        "lib/Analysis/AliasAnalysis.cpp",
+        "lib/Analysis/AliasSetTracker.cpp",
+        "lib/Analysis/BasicAliasAnalysis.cpp",
+        "lib/Analysis/BranchProbabilityInfo.cpp",
+        "lib/Analysis/CaptureTracking.cpp",
+        "lib/Analysis/ConstantFolding.cpp",
+        "lib/Analysis/DebugInfo.cpp",
+        "lib/Analysis/DIBuilder.cpp",
+        "lib/Analysis/InstructionSimplify.cpp",
+        "lib/Analysis/IVUsers.cpp",
+        "lib/Analysis/Loads.cpp",
+        "lib/Analysis/LoopInfo.cpp",
+        "lib/Analysis/LoopPass.cpp",
+        "lib/Analysis/MemoryBuiltins.cpp",
+        "lib/Analysis/MemoryDependenceAnalysis.cpp",
+        "lib/Analysis/NoAliasAnalysis.cpp",
+        "lib/Analysis/PathNumbering.cpp",
+        "lib/Analysis/PHITransAddr.cpp",
+        "lib/Analysis/ProfileInfo.cpp",
+        "lib/Analysis/ScalarEvolution.cpp",
+        "lib/Analysis/ScalarEvolutionExpander.cpp",
+        "lib/Analysis/ScalarEvolutionNormalization.cpp",
+        "lib/Analysis/TypeBasedAliasAnalysis.cpp",
+        "lib/Analysis/ValueTracking.cpp",
+        "lib/CodeGen/SelectionDAG/DAGCombiner.cpp",
+        "lib/CodeGen/SelectionDAG/FastISel.cpp",
+        "lib/CodeGen/SelectionDAG/FunctionLoweringInfo.cpp",
+        "lib/CodeGen/SelectionDAG/InstrEmitter.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeDAG.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeIntegerTypes.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeTypes.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeTypesGeneric.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp",
+        "lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp",
+        "lib/CodeGen/SelectionDAG/ScheduleDAGFast.cpp",
+        "lib/CodeGen/SelectionDAG/ScheduleDAGList.cpp",
+        "lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp",
+        "lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp",
+        "lib/CodeGen/SelectionDAG/SelectionDAG.cpp",
+        "lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp",
+        "lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp",
+        "lib/CodeGen/SelectionDAG/SelectionDAGPrinter.cpp",
+        "lib/CodeGen/SelectionDAG/TargetLowering.cpp",
+        "lib/CodeGen/SelectionDAG/TargetSelectionDAGInfo.cpp",
+        "lib/CodeGen/AggressiveAntiDepBreaker.cpp",
+        "lib/CodeGen/AllocationOrder.cpp",
+        "lib/CodeGen/Analysis.cpp",
+        "lib/CodeGen/BranchFolding.cpp",
+        "lib/CodeGen/CalcSpillWeights.cpp",
+        "lib/CodeGen/CallingConvLower.cpp",
+        "lib/CodeGen/CodeGen.cpp",
+        "lib/CodeGen/CodePlacementOpt.cpp",
+        "lib/CodeGen/CriticalAntiDepBreaker.cpp",
+        "lib/CodeGen/DeadMachineInstructionElim.cpp",
+        "lib/CodeGen/DwarfEHPrepare.cpp",
+        "lib/CodeGen/EdgeBundles.cpp",
+        "lib/CodeGen/ELFCodeEmitter.cpp",
+        "lib/CodeGen/ELFWriter.cpp",
+        "lib/CodeGen/ExecutionDepsFix.cpp",
+        "lib/CodeGen/ExpandISelPseudos.cpp",
+        "lib/CodeGen/ExpandPostRAPseudos.cpp",
+        "lib/CodeGen/GCMetadata.cpp",
+        "lib/CodeGen/GCStrategy.cpp",
+        "lib/CodeGen/IfConversion.cpp",
+        "lib/CodeGen/InlineSpiller.cpp",
+        "lib/CodeGen/InterferenceCache.cpp",
+        "lib/CodeGen/IntrinsicLowering.cpp",
+        "lib/CodeGen/LatencyPriorityQueue.cpp",
+        "lib/CodeGen/LexicalScopes.cpp",
+        "lib/CodeGen/LiveDebugVariables.cpp",
+        "lib/CodeGen/LiveIntervalAnalysis.cpp",
+        "lib/CodeGen/LiveInterval.cpp",
+        "lib/CodeGen/LiveIntervalUnion.cpp",
+        "lib/CodeGen/LiveRangeCalc.cpp",
+        "lib/CodeGen/LiveRangeEdit.cpp",
+        "lib/CodeGen/LiveStackAnalysis.cpp",
+        "lib/CodeGen/LiveVariables.cpp",
+        "lib/CodeGen/LLVMTargetMachine.cpp",
+        "lib/CodeGen/LocalStackSlotAllocation.cpp",
+        "lib/CodeGen/MachineBasicBlock.cpp",
+        "lib/CodeGen/MachineBlockFrequencyInfo.cpp",
+        "lib/CodeGen/MachineBranchProbabilityInfo.cpp",
+        "lib/CodeGen/MachineCSE.cpp",
+        "lib/CodeGen/MachineDominators.cpp",
+        "lib/CodeGen/MachineFunctionAnalysis.cpp",
+        "lib/CodeGen/MachineFunction.cpp",
+        "lib/CodeGen/MachineFunctionPass.cpp",
+        "lib/CodeGen/MachineFunctionPrinterPass.cpp",
+        "lib/CodeGen/MachineInstr.cpp",
+        "lib/CodeGen/MachineLICM.cpp",
+        "lib/CodeGen/MachineLoopInfo.cpp",
+        "lib/CodeGen/MachineLoopRanges.cpp",
+        "lib/CodeGen/MachineModuleInfo.cpp",
+        "lib/CodeGen/MachineModuleInfoImpls.cpp",
+        "lib/CodeGen/MachinePassRegistry.cpp",
+        "lib/CodeGen/MachineRegisterInfo.cpp",
+        "lib/CodeGen/MachineSink.cpp",
+        "lib/CodeGen/MachineSSAUpdater.cpp",
+        "lib/CodeGen/MachineVerifier.cpp",
+        "lib/CodeGen/ObjectCodeEmitter.cpp",
+        "lib/CodeGen/OcamlGC.cpp",
+        "lib/CodeGen/OptimizePHIs.cpp",
+        "lib/CodeGen/Passes.cpp",
+        "lib/CodeGen/PeepholeOptimizer.cpp",
+        "lib/CodeGen/PHIElimination.cpp",
+        "lib/CodeGen/PHIEliminationUtils.cpp",
+        "lib/CodeGen/PostRASchedulerList.cpp",
+        "lib/CodeGen/ProcessImplicitDefs.cpp",
+        "lib/CodeGen/PrologEpilogInserter.cpp",
+        "lib/CodeGen/PseudoSourceValue.cpp",
+        "lib/CodeGen/RegAllocBasic.cpp",
+        "lib/CodeGen/RegAllocFast.cpp",
+        "lib/CodeGen/RegAllocGreedy.cpp",
+        "lib/CodeGen/RegAllocLinearScan.cpp",
+        "lib/CodeGen/RegAllocPBQP.cpp",
+        "lib/CodeGen/RegisterClassInfo.cpp",
+        "lib/CodeGen/RegisterCoalescer.cpp",
+        "lib/CodeGen/RegisterScavenging.cpp",
+        "lib/CodeGen/RenderMachineFunction.cpp",
+        "lib/CodeGen/ScheduleDAG.cpp",
+        "lib/CodeGen/ScheduleDAGEmit.cpp",
+        "lib/CodeGen/ScheduleDAGInstrs.cpp",
+        "lib/CodeGen/ScheduleDAGPrinter.cpp",
+        "lib/CodeGen/ScoreboardHazardRecognizer.cpp",
+        "lib/CodeGen/ShadowStackGC.cpp",
+        "lib/CodeGen/ShrinkWrapping.cpp",
+        "lib/CodeGen/SjLjEHPrepare.cpp",
+        "lib/CodeGen/SlotIndexes.cpp",
+        "lib/CodeGen/Spiller.cpp",
+        "lib/CodeGen/SpillPlacement.cpp",
+        "lib/CodeGen/SplitKit.cpp",
+        "lib/CodeGen/Splitter.cpp",
+        "lib/CodeGen/StackProtector.cpp",
+        "lib/CodeGen/StackSlotColoring.cpp",
+        "lib/CodeGen/StrongPHIElimination.cpp",
+        "lib/CodeGen/TailDuplication.cpp",
+        "lib/CodeGen/TargetInstrInfoImpl.cpp",
+        "lib/CodeGen/TargetLoweringObjectFileImpl.cpp",
+        "lib/CodeGen/TwoAddressInstructionPass.cpp",
+        "lib/CodeGen/UnreachableBlockElim.cpp",
+        "lib/CodeGen/VirtRegMap.cpp",
+        "lib/CodeGen/VirtRegRewriter.cpp",
+        "lib/ExecutionEngine/JIT/Intercept.cpp",
+        "lib/ExecutionEngine/JIT/JIT.cpp",
+        "lib/ExecutionEngine/JIT/JITDebugRegisterer.cpp",
+        "lib/ExecutionEngine/JIT/JITDwarfEmitter.cpp",
+        "lib/ExecutionEngine/JIT/JITEmitter.cpp",
+        "lib/ExecutionEngine/JIT/JITMemoryManager.cpp",
+        "lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp",
+        "lib/ExecutionEngine/ExecutionEngine.cpp",
+        "lib/ExecutionEngine/TargetSelect.cpp",
+        "lib/MC/ELFObjectWriter.cpp",
+        "lib/MC/MachObjectWriter.cpp",
+        "lib/MC/MCAsmBackend.cpp",
+        "lib/MC/MCAsmInfoCOFF.cpp",
+        "lib/MC/MCAsmInfo.cpp",
+        "lib/MC/MCAsmInfoDarwin.cpp",
+        "lib/MC/MCAsmStreamer.cpp",
+        "lib/MC/MCAssembler.cpp",
+        "lib/MC/MCAtom.cpp",
+        "lib/MC/MCCodeEmitter.cpp",
+        "lib/MC/MCCodeGenInfo.cpp",
+        "lib/MC/MCContext.cpp",
+        "lib/MC/MCDisassembler.cpp",
+        "lib/MC/MCDwarf.cpp",
+        "lib/MC/MCELF.cpp",
+        "lib/MC/MCELFObjectTargetWriter.cpp",
+        "lib/MC/MCELFStreamer.cpp",
+        "lib/MC/MCExpr.cpp",
+        "lib/MC/MCInst.cpp",
+        "lib/MC/MCInstPrinter.cpp",
+        "lib/MC/MCInstrAnalysis.cpp",
+        "lib/MC/MCLabel.cpp",
+        "lib/MC/MCLoggingStreamer.cpp",
+        "lib/MC/MCMachObjectTargetWriter.cpp",
+        "lib/MC/MCMachOStreamer.cpp",
+        "lib/MC/MCModule.cpp",
+        "lib/MC/MCNullStreamer.cpp",
+        "lib/MC/MCObjectFileInfo.cpp",
+        "lib/MC/MCObjectStreamer.cpp",
+        "lib/MC/MCObjectWriter.cpp",
+        "lib/MC/MCPureStreamer.cpp",
+        "lib/MC/MCSectionCOFF.cpp",
+        "lib/MC/MCSection.cpp",
+        "lib/MC/MCSectionELF.cpp",
+        "lib/MC/MCSectionMachO.cpp",
+        "lib/MC/MCStreamer.cpp",
+        "lib/MC/MCSubtargetInfo.cpp",
+        "lib/MC/MCSymbol.cpp",
+        "lib/MC/MCTargetAsmLexer.cpp",
+        "lib/MC/MCValue.cpp",
+        "lib/MC/MCWin64EH.cpp",
+        "lib/MC/SubtargetFeature.cpp",
+        "lib/MC/WinCOFFObjectWriter.cpp",
+        "lib/MC/WinCOFFStreamer.cpp",
+        "lib/Support/Allocator.cpp",
+        "lib/Support/APFloat.cpp",
+        "lib/Support/APInt.cpp",
+        "lib/Support/APSInt.cpp",
+        "lib/Support/Atomic.cpp",
+        "lib/Support/BlockFrequency.cpp",
+        "lib/Support/BranchProbability.cpp",
+        "lib/Support/circular_raw_ostream.cpp",
+        "lib/Support/CommandLine.cpp",
+        "lib/Support/ConstantRange.cpp",
+        "lib/Support/CrashRecoveryContext.cpp",
+        "lib/Support/DAGDeltaAlgorithm.cpp",
+        "lib/Support/DataExtractor.cpp",
+        "lib/Support/Debug.cpp",
+        "lib/Support/DeltaAlgorithm.cpp",
+        "lib/Support/Disassembler.cpp",
+        "lib/Support/Dwarf.cpp",
+        "lib/Support/DynamicLibrary.cpp",
+        "lib/Support/Errno.cpp",
+        "lib/Support/ErrorHandling.cpp",
+        "lib/Support/FileUtilities.cpp",
+        "lib/Support/FoldingSet.cpp",
+        "lib/Support/FormattedStream.cpp",
+        "lib/Support/GraphWriter.cpp",
+        "lib/Support/Host.cpp",
+        "lib/Support/IncludeFile.cpp",
+        "lib/Support/IntEqClasses.cpp",
+        "lib/Support/IntervalMap.cpp",
+        "lib/Support/IsInf.cpp",
+        "lib/Support/IsNAN.cpp",
+        "lib/Support/ManagedStatic.cpp",
+        "lib/Support/MemoryBuffer.cpp",
+        "lib/Support/Memory.cpp",
+        "lib/Support/MemoryObject.cpp",
+        "lib/Support/Mutex.cpp",
+        "lib/Support/Path.cpp",
+        "lib/Support/PathV2.cpp",
+        "lib/Support/PluginLoader.cpp",
+        "lib/Support/PrettyStackTrace.cpp",
+        "lib/Support/Process.cpp",
+        "lib/Support/Program.cpp",
+        "lib/Support/raw_os_ostream.cpp",
+        "lib/Support/raw_ostream.cpp",
+        "lib/Support/Regex.cpp",
+        "lib/Support/RWMutex.cpp",
+        "lib/Support/SearchForAddressOfSpecialSymbol.cpp",
+        "lib/Support/Signals.cpp",
+        "lib/Support/SmallPtrSet.cpp",
+        "lib/Support/SmallVector.cpp",
+        "lib/Support/SourceMgr.cpp",
+        "lib/Support/Statistic.cpp",
+        "lib/Support/StringExtras.cpp",
+        "lib/Support/StringMap.cpp",
+        "lib/Support/StringPool.cpp",
+        "lib/Support/StringRef.cpp",
+        "lib/Support/system_error.cpp",
+        "lib/Support/SystemUtils.cpp",
+        "lib/Support/TargetRegistry.cpp",
+        "lib/Support/Threading.cpp",
+        "lib/Support/ThreadLocal.cpp",
+        "lib/Support/Timer.cpp",
+        "lib/Support/TimeValue.cpp",
+        "lib/Support/ToolOutputFile.cpp",
+        "lib/Support/Triple.cpp",
+        "lib/Support/Twine.cpp",
+        "lib/Support/Valgrind.cpp",
+        "lib/Target/Mangler.cpp",
+        "lib/Target/Target.cpp",
+        "lib/Target/TargetData.cpp",
+        "lib/Target/TargetELFWriterInfo.cpp",
+        "lib/Target/TargetFrameLowering.cpp",
+        "lib/Target/TargetInstrInfo.cpp",
+        "lib/Target/TargetLibraryInfo.cpp",
+        "lib/Target/TargetLoweringObjectFile.cpp",
+        "lib/Target/TargetMachine.cpp",
+        "lib/Target/TargetRegisterInfo.cpp",
+        "lib/Target/TargetSubtargetInfo.cpp",
+        "lib/Transforms/InstCombine/InstCombineAddSub.cpp",
+        "lib/Transforms/InstCombine/InstCombineAndOrXor.cpp",
+        "lib/Transforms/InstCombine/InstCombineCalls.cpp",
+        "lib/Transforms/InstCombine/InstCombineCasts.cpp",
+        "lib/Transforms/InstCombine/InstCombineCompares.cpp",
+        "lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp",
+        "lib/Transforms/InstCombine/InstCombineMulDivRem.cpp",
+        "lib/Transforms/InstCombine/InstCombinePHI.cpp",
+        "lib/Transforms/InstCombine/InstCombineSelect.cpp",
+        "lib/Transforms/InstCombine/InstCombineShifts.cpp",
+        "lib/Transforms/InstCombine/InstCombineSimplifyDemanded.cpp",
+        "lib/Transforms/InstCombine/InstCombineVectorOps.cpp",
+        "lib/Transforms/InstCombine/InstructionCombining.cpp",
+        "lib/Transforms/Scalar/ADCE.cpp",
+        "lib/Transforms/Scalar/CodeGenPrepare.cpp",
+        "lib/Transforms/Scalar/DeadStoreElimination.cpp",
+        "lib/Transforms/Scalar/GVN.cpp",
+        "lib/Transforms/Scalar/LICM.cpp",
+        "lib/Transforms/Scalar/LoopStrengthReduce.cpp",
+        "lib/Transforms/Scalar/Reassociate.cpp",
+        "lib/Transforms/Scalar/Reg2Mem.cpp",
+        "lib/Transforms/Scalar/ScalarReplAggregates.cpp",
+        "lib/Transforms/Scalar/SCCP.cpp",
+        "lib/Transforms/Scalar/SimplifyCFGPass.cpp",
+        "lib/Transforms/Utils/AddrModeMatcher.cpp",
+        "lib/Transforms/Utils/BasicBlockUtils.cpp",
+        "lib/Transforms/Utils/BreakCriticalEdges.cpp",
+        "lib/Transforms/Utils/BuildLibCalls.cpp",
+        "lib/Transforms/Utils/DemoteRegToStack.cpp",
+        "lib/Transforms/Utils/InstructionNamer.cpp",
+        "lib/Transforms/Utils/LCSSA.cpp",
+        "lib/Transforms/Utils/Local.cpp",
+        "lib/Transforms/Utils/LoopSimplify.cpp",
+        "lib/Transforms/Utils/LowerInvoke.cpp",
+        "lib/Transforms/Utils/LowerSwitch.cpp",
+        "lib/Transforms/Utils/Mem2Reg.cpp",
+        "lib/Transforms/Utils/PromoteMemoryToRegister.cpp",
+        "lib/Transforms/Utils/SimplifyCFG.cpp",
+        "lib/Transforms/Utils/SSAUpdater.cpp",
+        "lib/Transforms/Utils/UnifyFunctionExitNodes.cpp",
+        "lib/VMCore/AsmWriter.cpp",
+        "lib/VMCore/Attributes.cpp",
+        "lib/VMCore/AutoUpgrade.cpp",
+        "lib/VMCore/BasicBlock.cpp",
+        "lib/VMCore/ConstantFold.cpp",
+        "lib/VMCore/Constants.cpp",
+        "lib/VMCore/Core.cpp",
+        "lib/VMCore/DebugInfoProbe.cpp",
+        "lib/VMCore/DebugLoc.cpp",
+        "lib/VMCore/Dominators.cpp",
+        "lib/VMCore/Function.cpp",
+        "lib/VMCore/GCOV.cpp",
+        "lib/VMCore/Globals.cpp",
+        "lib/VMCore/GVMaterializer.cpp",
+        "lib/VMCore/InlineAsm.cpp",
+        "lib/VMCore/Instruction.cpp",
+        "lib/VMCore/Instructions.cpp",
+        "lib/VMCore/IntrinsicInst.cpp",
+        "lib/VMCore/IRBuilder.cpp",
+        "lib/VMCore/LeakDetector.cpp",
+        "lib/VMCore/LLVMContext.cpp",
+        "lib/VMCore/LLVMContextImpl.cpp",
+        "lib/VMCore/Metadata.cpp",
+        "lib/VMCore/Module.cpp",
+        "lib/VMCore/Pass.cpp",
+        "lib/VMCore/PassManager.cpp",
+        "lib/VMCore/PassRegistry.cpp",
+        "lib/VMCore/PrintModulePass.cpp",
+        "lib/VMCore/Type.cpp",
+        "lib/VMCore/Use.cpp",
+        "lib/VMCore/User.cpp",
+        "lib/VMCore/Value.cpp",
+        "lib/VMCore/ValueSymbolTable.cpp",
+        "lib/VMCore/ValueTypes.cpp",
+        "lib/VMCore/Verifier.cpp",
+    ],
+
+    arch: {
+        x86: {
+            local_include_dirs: [ "lib/Target/X86" ],
+
+            srcs: libLLVM_swiftshader_x86_srcs,
+        },
+
+        x86_64: {
+            local_include_dirs: [ "lib/Target/X86" ],
+
+            srcs: libLLVM_swiftshader_x86_srcs,
+        },
+    },
+
+    target: {
+        android: {
+            export_include_dirs: [ "include-android", "include" ],
+        },
+
+        linux: {
+            export_include_dirs: [ "include-linux", "include" ],
+        },
+
+        darwin: {
+            export_include_dirs: [ "include-osx", "include" ],
+        },
+    },
+}
diff --git a/third_party/llvm-subzero/Android.bp b/third_party/llvm-subzero/Android.bp
new file mode 100644
index 0000000..854fa8d
--- /dev/null
+++ b/third_party/llvm-subzero/Android.bp
@@ -0,0 +1,85 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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
+//
+//      http://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.
+//
+
+cc_library_static {
+    name: "libLLVMSupport_subzero",
+
+    defaults: [ "swiftshader_common_release" ],
+
+    device_supported: false,
+    host_supported: true,
+
+    cflags: [
+        "-D_GNU_SOURCE",
+        "-D__STDC_LIMIT_MACROS",
+        "-D__STDC_CONSTANT_MACROS",
+        "-D__STDC_FORMAT_MACROS",
+        "-DLOG_TAG=\"libsubzero\"",
+        "-Wno-unused-parameter",
+    ],
+
+    cppflags: [
+        "-Wno-sign-promo",
+    ],
+
+    srcs: [
+        "lib/Demangle/ItaniumDemangle.cpp",
+        "lib/Support/APInt.cpp",
+        "lib/Support/Atomic.cpp",
+        "lib/Support/circular_raw_ostream.cpp",
+        "lib/Support/CommandLine.cpp",
+        "lib/Support/ConvertUTF.cpp",
+        "lib/Support/ConvertUTFWrapper.cpp",
+        "lib/Support/Debug.cpp",
+        "lib/Support/Errno.cpp",
+        "lib/Support/ErrorHandling.cpp",
+        "lib/Support/FoldingSet.cpp",
+        "lib/Support/Hashing.cpp",
+        "lib/Support/Host.cpp",
+        "lib/Support/ManagedStatic.cpp",
+        "lib/Support/MemoryBuffer.cpp",
+        "lib/Support/Mutex.cpp",
+        "lib/Support/NativeFormatting.cpp",
+        "lib/Support/Path.cpp",
+        "lib/Support/Process.cpp",
+        "lib/Support/Program.cpp",
+        "lib/Support/raw_os_ostream.cpp",
+        "lib/Support/raw_ostream.cpp",
+        "lib/Support/regcomp.c",
+        "lib/Support/regerror.c",
+        "lib/Support/Regex.cpp",
+        "lib/Support/regexec.c",
+        "lib/Support/regfree.c",
+        "lib/Support/regstrlcpy.c",
+        "lib/Support/Signals.cpp",
+        "lib/Support/SmallPtrSet.cpp",
+        "lib/Support/SmallVector.cpp",
+        "lib/Support/StringExtras.cpp",
+        "lib/Support/StringMap.cpp",
+        "lib/Support/StringRef.cpp",
+        "lib/Support/StringSaver.cpp",
+        "lib/Support/TargetParser.cpp",
+        "lib/Support/Threading.cpp",
+        "lib/Support/Timer.cpp",
+        "lib/Support/Triple.cpp",
+        "lib/Support/Twine.cpp",
+    ],
+
+    export_include_dirs: [
+        "build/Android/include",
+        "include",
+    ],
+}
diff --git a/third_party/subzero/Android.bp b/third_party/subzero/Android.bp
new file mode 100644
index 0000000..cde1ac6
--- /dev/null
+++ b/third_party/subzero/Android.bp
@@ -0,0 +1,116 @@
+//
+// Copyright (C) 2018 The Android Open Source Project
+//
+// 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
+//
+//      http://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.
+//
+
+cc_library_static {
+    name: "libsubzero",
+
+    defaults: [ "swiftshader_common_release", "swiftshader_subzero" ],
+
+    device_supported: false,
+    host_supported: true,
+
+    cflags: [
+        "-D_GNU_SOURCE",
+        "-D__STDC_LIMIT_MACROS",
+        "-D__STDC_CONSTANT_MACROS",
+        "-D__STDC_FORMAT_MACROS",
+        "-DLOG_TAG=\"libsubzero\"",
+        "-Wno-unused-parameter",
+        "-Wno-error=undefined-var-template",
+        "-Wno-error=unused-lambda-capture",
+    ],
+
+    cppflags: [
+        "-Wno-sign-promo",
+        "-Wno-non-virtual-dtor",
+    ],
+
+    srcs: [
+        "src/IceAssembler.cpp",
+        "src/IceCfg.cpp",
+        "src/IceCfgNode.cpp",
+        "src/IceClFlags.cpp",
+        "src/IceELFObjectWriter.cpp",
+        "src/IceELFSection.cpp",
+        "src/IceFixups.cpp",
+        "src/IceGlobalContext.cpp",
+        "src/IceGlobalInits.cpp",
+        "src/IceInst.cpp",
+        "src/IceInstrumentation.cpp",
+        "src/IceIntrinsics.cpp",
+        "src/IceLiveness.cpp",
+        "src/IceLoopAnalyzer.cpp",
+        "src/IceMangling.cpp",
+        "src/IceMemory.cpp",
+        "src/IceOperand.cpp",
+        "src/IceRangeSpec.cpp",
+        "src/IceRegAlloc.cpp",
+        "src/IceRevision.cpp",
+        "src/IceRNG.cpp",
+        "src/IceSwitchLowering.cpp",
+        "src/IceTargetLowering.cpp",
+        "src/IceThreading.cpp",
+        "src/IceTimerTree.cpp",
+        "src/IceTypes.cpp",
+        "src/IceVariableSplitting.cpp",
+    ],
+
+    arch: {
+        arm: {
+            cflags : [ "-DSZTARGET=ARM32" ],
+
+            srcs: [
+                "src/IceAssemblerARM32.cpp",
+                "src/IceTargetLoweringARM32.cpp",
+                "src/IceInstARM32.cpp",
+            ],
+        },
+
+        mips: {
+            cflags : [ "-DSZTARGET=MIPS32" ],
+
+            srcs: [
+                "src/IceAssemblerMIPS32.cpp",
+                "src/IceTargetLoweringMIPS32.cpp",
+                "src/IceInstMIPS32.cpp",
+            ],
+        },
+
+        x86: {
+            cflags : [ "-DSZTARGET=X8632" ],
+
+            srcs: [
+                "src/IceTargetLoweringX8632.cpp",
+                "src/IceInstX8632.cpp",
+            ],
+        },
+
+        x86_64: {
+            cflags : [ "-DSZTARGET=X8664" ],
+
+            srcs: [
+                "src/IceTargetLoweringX8664.cpp",
+                "src/IceInstX8664.cpp",
+            ],
+        },
+    },
+
+    // FIXME: The IceCfg.h interface needs to be exported correctly
+    // FIXME: Exporting the whole src tree is broken
+    export_include_dirs: [ "pnacl-llvm/include", "." ],
+
+    static_libs: [ "libLLVMSupport_subzero" ],
+}