Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 1 | # Copyright 2020 The SwiftShader Authors. All Rights Reserved. |
| 2 | # |
| 3 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | # you may not use this file except in compliance with the License. |
| 5 | # You may obtain a copy of the License at |
| 6 | # |
| 7 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | # |
| 9 | # Unless required by applicable law or agreed to in writing, software |
| 10 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | # See the License for the specific language governing permissions and |
| 13 | # limitations under the License. |
Nicolas Capens | b8afba1 | 2017-05-03 13:37:29 -0400 | [diff] [blame] | 14 | |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 15 | set(ROOT_PROJECT_COMPILE_OPTIONS |
| 16 | ${SWIFTSHADER_COMPILE_OPTIONS} |
| 17 | ${WARNINGS_AS_ERRORS} |
| 18 | ) |
| 19 | |
| 20 | set(SUBZERO_SRC_FILES |
| 21 | src/IceAssembler.cpp |
| 22 | src/IceCfg.cpp |
| 23 | src/IceCfgNode.cpp |
| 24 | src/IceClFlags.cpp |
| 25 | src/IceELFObjectWriter.cpp |
| 26 | src/IceELFSection.cpp |
| 27 | src/IceFixups.cpp |
| 28 | src/IceGlobalContext.cpp |
| 29 | src/IceGlobalInits.cpp |
| 30 | src/IceInst.cpp |
| 31 | src/IceInstrumentation.cpp |
| 32 | src/IceIntrinsics.cpp |
| 33 | src/IceLiveness.cpp |
| 34 | src/IceLoopAnalyzer.cpp |
| 35 | src/IceMangling.cpp |
| 36 | src/IceMemory.cpp |
| 37 | src/IceOperand.cpp |
| 38 | src/IceRangeSpec.cpp |
| 39 | src/IceRegAlloc.cpp |
| 40 | src/IceRevision.cpp |
| 41 | src/IceRNG.cpp |
| 42 | src/IceSwitchLowering.cpp |
| 43 | src/IceTargetLowering.cpp |
| 44 | src/IceThreading.cpp |
| 45 | src/IceTimerTree.cpp |
| 46 | src/IceTypes.cpp |
| 47 | src/IceVariableSplitting.cpp |
| 48 | ) |
| 49 | |
| 50 | if(ARCH STREQUAL "x86_64") |
| 51 | list(APPEND SUBZERO_SRC_FILES |
| 52 | src/IceTargetLoweringX86.cpp |
| 53 | src/IceInstX8664.cpp |
| 54 | src/IceTargetLoweringX8664.cpp |
Nicolas Capens | b8afba1 | 2017-05-03 13:37:29 -0400 | [diff] [blame] | 55 | ) |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 56 | set(SUBZERO_TARGET_CPU X8664) |
| 57 | elseif(ARCH STREQUAL "x86") |
| 58 | list(APPEND SUBZERO_SRC_FILES |
| 59 | src/IceTargetLoweringX86.cpp |
| 60 | src/IceInstX8632.cpp |
| 61 | src/IceTargetLoweringX8632.cpp |
| 62 | ) |
| 63 | set(SUBZERO_TARGET_CPU X8632) |
| 64 | elseif(ARCH STREQUAL "arm") |
| 65 | list(APPEND SUBZERO_SRC_FILES |
| 66 | src/IceAssemblerARM32.cpp |
| 67 | src/IceInstARM32.cpp |
| 68 | src/IceTargetLoweringARM32.cpp |
| 69 | ) |
| 70 | set(SUBZERO_TARGET_CPU ARM32) |
| 71 | elseif(ARCH STREQUAL "mipsel") |
| 72 | list(APPEND SUBZERO_SRC_FILES |
| 73 | src/IceAssemblerMIPS32.cpp |
| 74 | src/IceInstMIPS32.cpp |
| 75 | src/IceTargetLoweringMIPS32.cpp |
| 76 | ) |
| 77 | set(SUBZERO_TARGET_CPU MIPS32) |
Nicolas Capens | b8afba1 | 2017-05-03 13:37:29 -0400 | [diff] [blame] | 78 | else() |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 79 | message(FATAL_ERROR "Architecture '${ARCH}' not supported by Subzero") |
Nicolas Capens | b8afba1 | 2017-05-03 13:37:29 -0400 | [diff] [blame] | 80 | endif() |
| 81 | |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 82 | if(WIN32) |
| 83 | list(APPEND SUBZERO_COMPILE_OPTIONS |
| 84 | "/wd4146" # unary minus operator applied to unsigned type, result still unsigned |
| 85 | "/wd4334" # ''operator' : result of 32-bit shift implicitly converted to 64 bits (was 64-bit shift intended?) |
| 86 | "/wd4996" # The POSIX name for this item is deprecated. Instead, use the ISO C and C++ conformant name: new_name. |
| 87 | ) |
Nicolas Capens | b8afba1 | 2017-05-03 13:37:29 -0400 | [diff] [blame] | 88 | endif() |
| 89 | |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 90 | add_library(subzero STATIC EXCLUDE_FROM_ALL |
| 91 | ${SUBZERO_SRC_FILES} |
| 92 | ) |
Nicolas Capens | b8afba1 | 2017-05-03 13:37:29 -0400 | [diff] [blame] | 93 | |
Antonio Maiorano | 4bde1c3 | 2020-03-27 15:01:53 -0400 | [diff] [blame] | 94 | set_target_properties(subzero PROPERTIES |
| 95 | POSITION_INDEPENDENT_CODE 1 |
| 96 | FOLDER "Subzero" |
| 97 | ) |
| 98 | |
| 99 | target_include_directories(subzero |
| 100 | PUBLIC |
| 101 | # Add lib root as include dir, so client code can do #include "src/..." |
| 102 | # TODO: Split out headers into separate 'include' directory. |
| 103 | "." |
| 104 | "pnacl-llvm/include" |
| 105 | ) |
| 106 | |
| 107 | target_compile_options(subzero |
| 108 | PUBLIC |
| 109 | ${ROOT_PROJECT_COMPILE_OPTIONS} |
| 110 | ${SUBZERO_COMPILE_OPTIONS} |
| 111 | ) |
| 112 | |
| 113 | target_compile_definitions(subzero |
| 114 | PUBLIC |
| 115 | "SZTARGET=${SUBZERO_TARGET_CPU}" |
| 116 | "ALLOW_DUMP=0" |
| 117 | "ALLOW_TIMERS=0" |
| 118 | "ALLOW_LLVM_CL=0" |
| 119 | "ALLOW_LLVM_IR=0" |
| 120 | "ALLOW_LLVM_IR_AS_INPUT=0" |
| 121 | "ALLOW_MINIMAL_BUILD=0" |
| 122 | "ALLOW_WASM=0" |
| 123 | "ICE_THREAD_LOCAL_HACK=0" |
| 124 | PRIVATE |
| 125 | $<$<BOOL:${WIN32}>:"SUBZERO_USE_MICROSOFT_ABI"> |
| 126 | ) |
| 127 | |
| 128 | target_link_libraries(subzero |
| 129 | PUBLIC |
| 130 | llvm-subzero |
| 131 | ) |