2022-12-19 14:37:51 +00:00
|
|
|
/*
|
|
|
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
|
|
*
|
|
|
|
* 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.
|
|
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <filesystem>
|
|
|
|
#include <map>
|
|
|
|
#include <set>
|
2023-08-16 20:40:36 +01:00
|
|
|
#include <span>
|
2022-12-19 14:37:51 +00:00
|
|
|
#include <string>
|
|
|
|
|
2023-04-26 16:20:53 +01:00
|
|
|
#include "oi/ContainerInfo.h"
|
2023-06-22 17:27:21 +01:00
|
|
|
#include "oi/Features.h"
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
namespace fs = std::filesystem;
|
|
|
|
|
2023-07-26 15:31:53 +01:00
|
|
|
namespace oi::detail {
|
|
|
|
|
2022-12-19 14:37:51 +00:00
|
|
|
class FuncGen {
|
|
|
|
public:
|
2023-08-16 20:40:36 +01:00
|
|
|
static void DeclareExterns(std::string& code);
|
2023-09-27 02:14:23 +01:00
|
|
|
static void DefineJitLog(std::string& code, FeatureSet features);
|
2023-08-16 20:40:36 +01:00
|
|
|
|
2023-03-02 15:47:11 +00:00
|
|
|
static void DeclareStoreData(std::string& testCode);
|
|
|
|
static void DefineStoreData(std::string& testCode);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-03-02 15:47:11 +00:00
|
|
|
static void DeclareEncodeData(std::string& testCode);
|
|
|
|
static void DefineEncodeData(std::string& testCode);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-03-02 15:47:11 +00:00
|
|
|
static void DeclareEncodeDataSize(std::string& testCode);
|
|
|
|
static void DefineEncodeDataSize(std::string& testCode);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
|
|
|
bool DeclareGetSizeFuncs(std::string& testCode,
|
2023-03-21 17:52:28 +00:00
|
|
|
const ContainerInfoRefSet& containerInfo,
|
2023-07-26 15:31:53 +01:00
|
|
|
FeatureSet features);
|
2022-12-19 14:37:51 +00:00
|
|
|
bool DefineGetSizeFuncs(std::string& testCode,
|
2023-03-21 17:52:28 +00:00
|
|
|
const ContainerInfoRefSet& containerInfo,
|
2023-07-26 15:31:53 +01:00
|
|
|
FeatureSet features);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-03-02 15:47:11 +00:00
|
|
|
static void DeclareGetContainer(std::string& testCode);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-03-02 15:47:11 +00:00
|
|
|
static void DeclareGetSize(std::string& testCode, const std::string& type);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-08-16 20:40:36 +01:00
|
|
|
static void DefineTopLevelIntrospect(std::string& code,
|
2023-10-31 17:22:56 +00:00
|
|
|
const std::string& type,
|
|
|
|
const std::string& idToHash);
|
|
|
|
static void DefineTopLevelIntrospectNamed(
|
|
|
|
std::string& code,
|
|
|
|
const std::string& type,
|
|
|
|
const std::string& linkageName,
|
|
|
|
size_t exclusiveSize,
|
|
|
|
std::span<const std::string_view> typeNames);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-07-26 15:31:53 +01:00
|
|
|
static void DefineTopLevelGetSizeRef(std::string& testCode,
|
2023-10-31 17:22:56 +00:00
|
|
|
const std::string& type,
|
|
|
|
const std::string& idToHash,
|
2023-07-26 15:31:53 +01:00
|
|
|
FeatureSet features);
|
|
|
|
static void DefineTopLevelGetSizeRefTyped(std::string& testCode,
|
2023-10-31 17:22:56 +00:00
|
|
|
const std::string& type,
|
|
|
|
const std::string& idToHash,
|
2023-07-26 15:31:53 +01:00
|
|
|
FeatureSet features);
|
2023-06-26 11:07:44 +01:00
|
|
|
static void DefineOutputType(std::string& testCode,
|
2023-10-31 17:22:56 +00:00
|
|
|
const std::string& type,
|
|
|
|
const std::string& idToHash);
|
2023-08-16 20:40:36 +01:00
|
|
|
static void DefineTreeBuilderInstructions(
|
|
|
|
std::string& testCode,
|
2023-10-31 17:22:56 +00:00
|
|
|
const std::string& type,
|
|
|
|
const std::string& idToHash,
|
2023-08-16 20:40:36 +01:00
|
|
|
size_t exclusiveSize,
|
|
|
|
std::span<const std::string_view> typeNames);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-07-26 15:31:53 +01:00
|
|
|
static void DefineTopLevelGetSizeSmartPtr(std::string& testCode,
|
|
|
|
const std::string& rawType,
|
|
|
|
FeatureSet features);
|
2022-12-19 14:37:51 +00:00
|
|
|
|
2023-03-02 15:47:11 +00:00
|
|
|
static void DefineGetSizeTypedValueFunc(std::string& testCode,
|
|
|
|
const std::string& ctype);
|
2023-04-20 18:30:59 +01:00
|
|
|
|
|
|
|
static void DefineDataSegmentDataBuffer(std::string& testCode);
|
2023-08-16 20:40:36 +01:00
|
|
|
static void DefineBackInserterDataBuffer(std::string& code);
|
|
|
|
static void DefineBasicTypeHandlers(std::string& code, FeatureSet features);
|
|
|
|
|
|
|
|
static ContainerInfo GetOiArrayContainerInfo();
|
2022-12-19 14:37:51 +00:00
|
|
|
};
|
2023-07-26 15:31:53 +01:00
|
|
|
|
|
|
|
} // namespace oi::detail
|