forked from google/fully-homomorphic-encryption
-
Notifications
You must be signed in to change notification settings - Fork 0
/
common_runner.h
53 lines (46 loc) · 2.06 KB
/
common_runner.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// Copyright 2021 Google LLC
//
// 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.
#ifndef FULLY_HOMOMORPHIC_ENCRYPTION_TRANSPILER_COMMON_RUNNER_H_
#define FULLY_HOMOMORPHIC_ENCRYPTION_TRANSPILER_COMMON_RUNNER_H_
// Enccode/decode struct fields according to their order in the C++ declaration
// (DECLARATION), or reverse-declaration order (REVERSE). The latter order is
// issued by the XLS toolchain when emitting XLS IR code. The former is used
// when we convert XLS IR to Verilog netlists.
//
// UNDEFINED is an invalid setting.
//
// We maintain a single static flag of type StructEncodeOrder that we set at
// runtime, before code generated by the struct transpiler starts relying on the
// value.
enum class StructEncodeOrder { UNDEFINED = -1, REVERSE, DECLARATION };
// Retrieve the value of the static flag maintained. This method will assert
// when ther oder is UNDEFINED.
StructEncodeOrder GetStructEncodeOrder();
// Set the order in the static flag. Do not use this method. Use one of the
// two setters below.
void SetStructEncodeOrder(StructEncodeOrder order);
// Declare a static object of this type to set the encoding order to REVERSE.
struct StructReverseEncodeOrderSetter {
StructReverseEncodeOrderSetter() {
SetStructEncodeOrder(StructEncodeOrder::REVERSE);
}
};
// Declare a static object of this type to set the encoding order to
// DECLARATION.
struct StructDeclarationEncodeOrderSetter {
StructDeclarationEncodeOrderSetter() {
SetStructEncodeOrder(StructEncodeOrder::DECLARATION);
}
};
#endif // FULLY_HOMOMORPHIC_ENCRYPTION_TRANSPILER_COMMON_RUNNER_H_