Skip to content

Commit

Permalink
Update msvc 2017 (google#606)
Browse files Browse the repository at this point in the history
* Update windows build scripts for new VM
* Add build scripts for msvc 2019 release
* fix some windows build issues
  • Loading branch information
alan-baker authored Jul 10, 2020
1 parent d0eb905 commit e2a6275
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 20 deletions.
12 changes: 6 additions & 6 deletions kokoro/scripts/windows/build.bat
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,19 @@ set SRC=%cd%\github\clspv
set BUILD_TYPE=%1
set VS_VERSION=%2

choco install cmake --pre --yes --no-progress
choco upgrade cmake --pre --yes --no-progress

:: Force usage of python 3.6 and add cmake to the path.
set PATH=C:\python36;"C:\Program Files\CMake\bin";%PATH%
:: Force usage of python 3.6.
set PATH=C:\python36;%PATH%

cd %SRC%
python utils/fetch_sources.py

:: #########################################
:: set up msvc build env
:: #########################################
if %VS_VERSION% == 2017 (
if %VS_VERSION% == 2019 (
set GENERATOR="Visual Studio 16 2019"
echo "Using VS 2019..."
) else if %VS_VERSION% == 2017 (
set GENERATOR="Visual Studio 15 2017 Win64"
echo "Using VS 2017..."
) else if %VS_VERSION% == 2015 (
Expand Down
22 changes: 22 additions & 0 deletions kokoro/windows-msvc-2019-release/build.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
:: Copyright 2020 The Clspv Authors. All rights reserved.
::
:: 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.

@echo on

:: Find out the directory of the common build script.
set SCRIPT_DIR=%~dp0

:: Call with correct parameter
call %SCRIPT_DIR%\..\scripts\windows\build.bat Release 2019

15 changes: 15 additions & 0 deletions kokoro/windows-msvc-2019-release/continuous.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 The Clspv Authors. All rights reserved.
#
# 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.

build_file: "clspv/kokoro/windows-msvc-2019-release/build.bat"
15 changes: 15 additions & 0 deletions kokoro/windows-msvc-2019-release/presubmit.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# Copyright 2020 The Clspv Authors. All rights reserved.
#
# 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.

build_file: "clspv/kokoro/windows-msvc-2019-release/build.bat"
28 changes: 14 additions & 14 deletions lib/SPIRVProducerPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1757,25 +1757,25 @@ SPIRVID SPIRVProducerPass::getSPIRVType(Type *Ty) {
break;
}
case Type::IntegerTyID: {
uint32_t BitWidth = static_cast<uint32_t>(Ty->getPrimitiveSizeInBits());
uint32_t bit_width = static_cast<uint32_t>(Ty->getPrimitiveSizeInBits());

if (clspv::Option::Int8Support() && BitWidth == 8) {
if (clspv::Option::Int8Support() && bit_width == 8) {
addCapability(spv::CapabilityInt8);
} else if (BitWidth == 16) {
} else if (bit_width == 16) {
addCapability(spv::CapabilityInt16);
} else if (BitWidth == 64) {
} else if (bit_width == 64) {
addCapability(spv::CapabilityInt64);
}

if (BitWidth == 1) {
if (bit_width == 1) {
RID = addSPIRVInst<kTypes>(spv::OpTypeBool);
} else {
if (!clspv::Option::Int8Support() && BitWidth == 8) {
if (!clspv::Option::Int8Support() && bit_width == 8) {
// i8 is added to TypeMap as i32.
RID = getSPIRVType(Type::getIntNTy(Ty->getContext(), 32));
} else {
SPIRVOperandVec Ops;
Ops << BitWidth << 0 /* not signed */;
Ops << bit_width << 0 /* not signed */;
RID = addSPIRVInst<kTypes>(spv::OpTypeInt, Ops);
}
}
Expand All @@ -1784,15 +1784,15 @@ SPIRVID SPIRVProducerPass::getSPIRVType(Type *Ty) {
case Type::HalfTyID:
case Type::FloatTyID:
case Type::DoubleTyID: {
uint32_t BitWidth = static_cast<uint32_t>(Ty->getPrimitiveSizeInBits());
if (BitWidth == 16) {
uint32_t bit_width = static_cast<uint32_t>(Ty->getPrimitiveSizeInBits());
if (bit_width == 16) {
addCapability(spv::CapabilityFloat16);
} else if (BitWidth == 64) {
} else if (bit_width == 64) {
addCapability(spv::CapabilityFloat64);
}

SPIRVOperandVec Ops;
Ops << BitWidth;
Ops << bit_width;

RID = addSPIRVInst<kTypes>(spv::OpTypeFloat, Ops);
break;
Expand Down Expand Up @@ -1952,8 +1952,8 @@ SPIRVID SPIRVProducerPass::getSPIRVConstant(Constant *Cst) {
Opcode = spv::OpConstantNull;
}
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(Cst)) {
unsigned BitWidth = CI->getBitWidth();
if (BitWidth == 1) {
unsigned bit_width = CI->getBitWidth();
if (bit_width == 1) {
// If the bitwidth of constant is 1, generate OpConstantTrue or
// OpConstantFalse.
if (CI->getZExtValue()) {
Expand All @@ -1967,7 +1967,7 @@ SPIRVID SPIRVProducerPass::getSPIRVConstant(Constant *Cst) {
auto V = CI->getZExtValue();
LiteralNum.push_back(V & 0xFFFFFFFF);

if (BitWidth > 32) {
if (bit_width > 32) {
LiteralNum.push_back(V >> 32);
}

Expand Down

0 comments on commit e2a6275

Please sign in to comment.