xref: /aosp_15_r20/external/swiftshader/src/Reactor/Pragma.hpp (revision 03ce13f70fcc45d86ee91b7ee4cab1936a95046e)
1 // Copyright 2021 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.
14 
15 #ifndef rr_Pragma_hpp
16 #define rr_Pragma_hpp
17 
18 #include <variant>
19 
20 namespace rr {
21 
22 enum BooleanPragmaOption
23 {
24 	MemorySanitizerInstrumentation,
25 	InitializeLocalVariables,
26 };
27 
28 enum IntegerPragmaOption
29 {
30 	OptimizationLevel,  // O0, O1, O2 (default), O3
31 };
32 
33 void Pragma(BooleanPragmaOption option, bool enable);
34 void Pragma(IntegerPragmaOption option, int value);
35 
36 class ScopedPragma
37 {
38 public:
39 	ScopedPragma(BooleanPragmaOption option, bool enable);
40 	ScopedPragma(IntegerPragmaOption option, int value);
41 
42 	~ScopedPragma();
43 
44 private:
45 	struct BooleanPragma
46 	{
47 		BooleanPragmaOption option;
48 		bool enable;
49 	};
50 
51 	struct IntegerPragma
52 	{
53 		IntegerPragmaOption option;
54 		int value;
55 	};
56 
57 	std::variant<BooleanPragma, IntegerPragma> oldState;
58 };
59 
60 }  // namespace rr
61 
62 #endif  // rr_Pragma_hpp
63