Skip to content

Commit db565ec

Browse files
sys-igcigcbot
authored andcommitted
[Autobackout][FunctionalRegression]Revert of change: 3e008a9: RTStackReflection refactor
RTStackReflection refactor
1 parent 3e008a9 commit db565ec

File tree

14 files changed

+322
-528
lines changed

14 files changed

+322
-528
lines changed

IGC/AdaptorCommon/RayTracing/API/RayDispatchGlobalData.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SPDX-License-Identifier: MIT
2525
// We need to disable the warnings in such way because this C++ file may be compiled with Clang, GCC, and Microsoft
2626
// Visual Studio Compiler This works around (at least) two known problems:
2727
// - QuickBuild treats compiler warnings as errors
28-
// - IRBuilderGenerator.exe generates warnings when compiling this file
28+
// - RTStackReflection.exe generates warnings when compiling this file
2929
//
3030
// The only macros that are used by the main code are:
3131
// DISABLE_WARNING_PUSH

IGC/AdaptorCommon/RayTracing/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,5 @@
66
#
77
#============================ end_copyright_notice =============================
88

9+
add_subdirectory(RTStackReflection)
910
add_subdirectory(RTStackReflectionIRBG)

IGC/AdaptorCommon/RayTracing/RTBuilder.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ class RTBuilder : public IGCIRBuilder<> {
362362

363363

364364
private:
365-
#include "AutoGenRTStackReflectionPrivate.h"
365+
#include "AutoGenRTStackAccessPrivate.h"
366366
public:
367-
#include "AutoGenRTStackReflectionPublic.h"
367+
#include "AutoGenRTStackAccessPublic.h"
368368
public:
369369
Type *getSMStack2Ty() const;
370370
Type *getRTStack2Ty() const;

IGC/AdaptorCommon/RayTracing/RTStackFormat.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ SPDX-License-Identifier: MIT
2525
// We need to disable the warnings in such way because this C++ file may be compiled with Clang, GCC, and Microsoft
2626
// Visual Studio Compiler This works around (at least) two known problems:
2727
// - QuickBuild treats compiler warnings as errors
28-
// - IRBuilderGenerator.exe generates warnings when compiling this file
28+
// - RTStackReflection.exe generates warnings when compiling this file
2929
//
3030
// The only macros that are used by the main code are:
3131
// DISABLE_WARNING_PUSH
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#=========================== begin_copyright_notice ============================
2+
#
3+
# Copyright (C) 2019-2021 Intel Corporation
4+
#
5+
# SPDX-License-Identifier: MIT
6+
#
7+
#============================ end_copyright_notice =============================
8+
9+
add_definitions(-D_CRT_SECURE_NO_WARNINGS -DISTDLIB_UMD)
10+
11+
# have all configurations output a .pdb.
12+
if (MSVC)
13+
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /DEBUG")
14+
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /OPT:REF /OPT:ICF")
15+
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE-INTERNAL "${CMAKE_SHARED_LINKER_FLAGS_RELEASE-INTERNAL} /OPT:REF /OPT:ICF")
16+
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zi")
17+
endif()
18+
19+
set(IGC_BUILD__PROJ__RTStackReflection "${IGC_BUILD__PROJ_NAME_PREFIX}RTStackReflection")
20+
set(IGC_BUILD__PROJ__RTStackReflection "${IGC_BUILD__PROJ__RTStackReflection}" PARENT_SCOPE)
21+
set(IGC_BUILD__PROJ_LABEL__RTStackReflection "${IGC_BUILD__PROJ__RTStackReflection}")
22+
23+
set(IGC_BUILD__SRC__RTStackReflection
24+
"${CMAKE_CURRENT_SOURCE_DIR}/main.cpp"
25+
"${CMAKE_CURRENT_SOURCE_DIR}/reflection.cpp"
26+
"${CMAKE_CURRENT_SOURCE_DIR}/shared.h"
27+
)
28+
29+
set_source_files_properties("${CMAKE_CURRENT_SOURCE_DIR}/reflection.cpp" PROPERTIES HEADER_FILE_ONLY TRUE)
30+
31+
igc_imported_tool("${IGC_BUILD__PROJ__RTStackReflection}" RTStackReflection)
32+
33+
if(NOT TARGET ${IGC_BUILD__PROJ__RTStackReflection})
34+
add_executable("${IGC_BUILD__PROJ__RTStackReflection}"
35+
${IGC_BUILD__SRC__RTStackReflection}
36+
)
37+
38+
set_target_properties("${IGC_BUILD__PROJ__RTStackReflection}" PROPERTIES FOLDER "Tools")
39+
40+
target_link_libraries(${IGC_BUILD__PROJ__RTStackReflection}
41+
${IGC_BUILD__LLVM_LIBS_TO_LINK})
42+
43+
target_include_directories(${IGC_BUILD__PROJ__RTStackReflection} PUBLIC
44+
"${CMAKE_CURRENT_SOURCE_DIR}/../"
45+
)
46+
endif()
47+
48+
if(MSVC)
49+
#set up standard defines from the common WDK path.
50+
bs_set_wdk(${IGC_BUILD__PROJ__RTStackReflection})
51+
endif()
52+

IGC/IRBuilderGenerator/main.cpp renamed to IGC/AdaptorCommon/RayTracing/RTStackReflection/main.cpp

Lines changed: 8 additions & 171 deletions
Original file line numberDiff line numberDiff line change
@@ -60,67 +60,20 @@ SPDX-License-Identifier: MIT
6060
#include "llvm/Transforms/Utils/UnifyFunctionExitNodes.h"
6161
#include "llvm/Transforms/Utils.h"
6262
#include "llvmWrapper/IR/Instructions.h"
63-
#include "llvm/Support/YAMLTraits.h"
64-
#include "llvmWrapper/Support/YAMLParser.h"
6563
#include "common/LLVMWarningsPop.hpp"
6664

65+
#include "shared.h"
66+
6767
#include <map>
6868
#include <optional>
6969

7070
using namespace llvm;
7171

72-
// Address space descriptor from YAML
73-
struct AddressSpaceDesc {
74-
std::string name;
75-
std::string description;
76-
bool constant = false;
77-
unsigned AS = 0; // Will be auto-assigned based on order
78-
};
79-
80-
constexpr unsigned FIRST_ADDRSPACE = 100;
81-
82-
// YAML parsing traits
83-
namespace llvm {
84-
namespace yaml {
85-
template <> struct MappingTraits<AddressSpaceDesc> {
86-
static void mapping(IO &io, AddressSpaceDesc &desc) {
87-
io.mapRequired("name", desc.name);
88-
io.mapRequired("description", desc.description);
89-
io.mapRequired("constant", desc.constant);
90-
}
91-
};
92-
} // namespace yaml
93-
} // namespace llvm
94-
95-
LLVM_YAML_IS_SEQUENCE_VECTOR(AddressSpaceDesc)
96-
97-
struct AddressSpaceConfig {
98-
std::vector<AddressSpaceDesc> address_spaces;
99-
};
100-
101-
namespace llvm {
102-
namespace yaml {
103-
template <> struct MappingTraits<AddressSpaceConfig> {
104-
static void mapping(IO &io, AddressSpaceConfig &config) { io.mapRequired("address_spaces", config.address_spaces); }
105-
};
106-
} // namespace yaml
107-
} // namespace llvm
108-
109-
// Global storage for address space info loaded from YAML
110-
static std::vector<AddressSpaceDesc> LoadedAddrspaces;
111-
11272
static cl::opt<std::string> InputFilename(cl::Positional, cl::desc("<input bitcode file>"), cl::value_desc("filename"),
113-
cl::init(""));
73+
cl::Required);
11474

11575
static cl::opt<std::string> OutputFilename(cl::Positional, cl::desc("<output header file>"), cl::value_desc("header"),
116-
cl::init(""));
117-
118-
static cl::opt<std::string> YamlPath("yaml-path", cl::desc("Path to address space descriptor YAML file"),
119-
cl::value_desc("yaml"), cl::init(""));
120-
121-
static cl::opt<std::string> GenDescPath("gen-desc",
122-
cl::desc("Generate address space descriptor header at specified path"),
123-
cl::value_desc("path"), cl::init(""));
76+
cl::Required);
12477

12578
static cl::opt<bool> DoMangle("mangle-names", cl::desc("Mangles all strings"), cl::init(false));
12679

@@ -129,7 +82,7 @@ enum class FuncScope { PRIVATE, PUBLIC };
12982
static cl::opt<FuncScope> AutogenScope("scope", cl::desc("Which functions to process"),
13083
cl::values(clEnumValN(FuncScope::PRIVATE, "private", "private header"),
13184
clEnumValN(FuncScope::PUBLIC, "public", "public header")),
132-
cl::init(FuncScope::PRIVATE));
85+
cl::Required);
13386

13487
using HoleMap = MapVector<const Type *, std::string>;
13588
using AlignMap = DenseMap<const Type *, uint32_t>;
@@ -614,7 +567,7 @@ bool processCreate(const Function &F, raw_ostream &OS, const AnnotationMap &Anno
614567
SymbolTracker SymTracker;
615568
AddrspaceToValueMap AddrMap;
616569
SmallDenseSet<uint32_t> ReservedAddrspaces;
617-
for (auto &ASInfo : LoadedAddrspaces)
570+
for (auto &ASInfo : ReservedAS)
618571
ReservedAddrspaces.insert(ASInfo.AS);
619572
for (auto &Arg : F.args()) {
620573
SymTracker.addArg(&Arg);
@@ -1059,8 +1012,8 @@ bool process(const Module &M, raw_ostream &OS) {
10591012

10601013
void markInvariant(Module &M) {
10611014
SmallDenseSet<uint32_t> ConstantAS;
1062-
for (auto &ASInfo : LoadedAddrspaces) {
1063-
if (ASInfo.constant)
1015+
for (auto &ASInfo : ReservedAS) {
1016+
if (ASInfo.Constant)
10641017
ConstantAS.insert(ASInfo.AS);
10651018
}
10661019

@@ -1119,99 +1072,6 @@ void preprocess(Module &M) {
11191072
rewriteAnonTypes(M);
11201073
}
11211074

1122-
bool loadAddressSpacesFromYAML(const std::string &YamlPath) {
1123-
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFile(YamlPath);
1124-
if (std::error_code EC = FileOrErr.getError()) {
1125-
errs() << "Error opening YAML file '" << YamlPath << "': " << EC.message() << "\n";
1126-
return false;
1127-
}
1128-
1129-
yaml::Input YamlInput(FileOrErr.get()->getBuffer());
1130-
AddressSpaceConfig Config;
1131-
YamlInput >> Config;
1132-
1133-
if (YamlInput.error()) {
1134-
errs() << "Error parsing YAML file '" << YamlPath << "'\n";
1135-
return false;
1136-
}
1137-
1138-
LoadedAddrspaces.clear();
1139-
for (size_t i = 0; i < Config.address_spaces.size(); i++) {
1140-
auto &desc = Config.address_spaces[i];
1141-
desc.AS = FIRST_ADDRSPACE + static_cast<uint32_t>(i);
1142-
LoadedAddrspaces.push_back(desc);
1143-
}
1144-
1145-
return true;
1146-
}
1147-
1148-
bool generateDescriptorHeader(const std::string &YamlPath, const std::string &OutputPath) {
1149-
// Load the YAML configuration
1150-
ErrorOr<std::unique_ptr<MemoryBuffer>> FileOrErr = MemoryBuffer::getFile(YamlPath);
1151-
if (std::error_code EC = FileOrErr.getError()) {
1152-
errs() << "Error opening YAML file '" << YamlPath << "': " << EC.message() << "\n";
1153-
return false;
1154-
}
1155-
1156-
yaml::Input YamlInput(FileOrErr.get()->getBuffer());
1157-
AddressSpaceConfig Config;
1158-
YamlInput >> Config;
1159-
1160-
if (YamlInput.error()) {
1161-
errs() << "Error parsing YAML file '" << YamlPath << "'\n";
1162-
return false;
1163-
}
1164-
1165-
// Open output file
1166-
std::error_code EC;
1167-
sys::fs::OpenFlags fsFlags = sys::fs::OF_TextWithCRLF;
1168-
raw_fd_ostream outfile(OutputPath, EC, fsFlags);
1169-
1170-
if (EC) {
1171-
errs() << "Couldn't open output file '" << OutputPath << "' for writing: " << EC.message() << "\n";
1172-
return false;
1173-
}
1174-
1175-
// Write the header
1176-
outfile << "// AUTOGENERATED FILE - DO NOT EDIT\n";
1177-
outfile << "// Generated from: " << YamlPath << "\n\n";
1178-
outfile << "#pragma once\n\n";
1179-
outfile << "struct AddrspaceInfo {\n";
1180-
outfile << " unsigned AS;\n";
1181-
outfile << " bool Constant;\n";
1182-
outfile << " constexpr AddrspaceInfo(unsigned AS, bool Constant) : AS(AS), Constant(Constant) {}\n";
1183-
outfile << "};\n\n";
1184-
outfile << "constexpr AddrspaceInfo ReservedAS[] = {\n";
1185-
outfile << " // clang-format off\n";
1186-
1187-
for (size_t i = 0; i < Config.address_spaces.size(); i++) {
1188-
auto &desc = Config.address_spaces[i];
1189-
unsigned AS = FIRST_ADDRSPACE + static_cast<unsigned>(i);
1190-
const char *constant = desc.constant ? "true " : "false";
1191-
outfile << " AddrspaceInfo{ " << AS << ", " << constant << " }, // " << desc.name << ": " << desc.description
1192-
<< "\n";
1193-
}
1194-
1195-
outfile << " // clang-format on\n";
1196-
outfile << "};\n\n";
1197-
1198-
// Generate address space defines
1199-
outfile << "#if defined(__clang__)\n";
1200-
for (size_t i = 0; i < Config.address_spaces.size(); i++) {
1201-
auto &desc = Config.address_spaces[i];
1202-
outfile << "// " << desc.description << "\n";
1203-
outfile << "#define " << desc.name << " __attribute__((address_space(ReservedAS[" << i << "].AS)))\n";
1204-
}
1205-
outfile << "#else\n";
1206-
for (size_t i = 0; i < Config.address_spaces.size(); i++) {
1207-
auto &desc = Config.address_spaces[i];
1208-
outfile << "#define " << desc.name << "\n";
1209-
}
1210-
outfile << "#endif // __clang__\n";
1211-
1212-
return true;
1213-
}
1214-
12151075
int main(int argc, char **argv) {
12161076
sys::PrintStackTraceOnErrorSignal(argv[0]);
12171077
llvm::PrettyStackTraceProgram X(argc, argv);
@@ -1227,29 +1087,6 @@ Generate code for the specified bitcode.
12271087
if (!cl::ParseCommandLineOptions(argc, argv, Overview))
12281088
return 1;
12291089

1230-
// Handle --gen-desc mode: generate address space descriptor header and exit
1231-
if (!GenDescPath.empty()) {
1232-
if (YamlPath.empty()) {
1233-
errs() << "Error: --gen-desc requires --yaml-path to be specified\n";
1234-
return 1;
1235-
}
1236-
return generateDescriptorHeader(YamlPath, GenDescPath) ? 0 : 1;
1237-
}
1238-
1239-
// Validate required arguments for normal mode
1240-
if (InputFilename.empty() || OutputFilename.empty()) {
1241-
errs() << "Error: input bitcode file and output header file are required\n";
1242-
return 1;
1243-
}
1244-
1245-
// Load address space configuration from YAML if provided
1246-
if (!YamlPath.empty()) {
1247-
if (!loadAddressSpacesFromYAML(YamlPath)) {
1248-
errs() << "Failed to load address space configuration from: " << YamlPath << "\n";
1249-
return 1;
1250-
}
1251-
}
1252-
12531090
LLVMContext Context;
12541091
SMDiagnostic Err;
12551092

0 commit comments

Comments
 (0)