/src/spirv-tools/source/opt/remove_dontinline_pass.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | // Copyright (c) 2022 Google LLC |
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. |
14 | | |
15 | | #include "source/opt/remove_dontinline_pass.h" |
16 | | |
17 | | namespace spvtools { |
18 | | namespace opt { |
19 | | |
20 | 0 | Pass::Status RemoveDontInline::Process() { |
21 | 0 | bool modified = false; |
22 | 0 | modified = ClearDontInlineFunctionControl(); |
23 | 0 | return (modified ? Status::SuccessWithChange : Status::SuccessWithoutChange); |
24 | 0 | } |
25 | | |
26 | 0 | bool RemoveDontInline::ClearDontInlineFunctionControl() { |
27 | 0 | bool modified = false; |
28 | 0 | for (auto& func : *get_module()) { |
29 | 0 | ClearDontInlineFunctionControl(&func); |
30 | 0 | } |
31 | 0 | return modified; |
32 | 0 | } |
33 | | |
34 | 0 | bool RemoveDontInline::ClearDontInlineFunctionControl(Function* function) { |
35 | 0 | constexpr uint32_t kFunctionControlInOperandIdx = 0; |
36 | 0 | Instruction* function_inst = &function->DefInst(); |
37 | 0 | uint32_t function_control = |
38 | 0 | function_inst->GetSingleWordInOperand(kFunctionControlInOperandIdx); |
39 | |
|
40 | 0 | if ((function_control & uint32_t(spv::FunctionControlMask::DontInline)) == |
41 | 0 | 0) { |
42 | 0 | return false; |
43 | 0 | } |
44 | 0 | function_control &= ~uint32_t(spv::FunctionControlMask::DontInline); |
45 | 0 | function_inst->SetInOperand(kFunctionControlInOperandIdx, {function_control}); |
46 | 0 | return true; |
47 | 0 | } |
48 | | |
49 | | } // namespace opt |
50 | | } // namespace spvtools |