CodeQL / Analyze (actions) (push) Canceled after 0s
CodeQL / Analyze (python) (push) Canceled after 0s
pre-commit / pre-commit (push) Canceled after 0s
Multi-Arch CI / setup (push) Canceled after 0s
Publish build_manylinux_x86_64 images / publish_build_manylinux_x86_64 (push) Canceled after 0s
Setup (Multi-Arch) / setup (push) Canceled after 0s
Multi-Arch CI / Linux::${{ fromJSON(needs.setup.outputs.linux_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubi10 image / publish_no_rocm_image_ubi10 (push) Canceled after 0s
Multi-Arch CI / Windows::${{ fromJSON(needs.setup.outputs.windows_build_config || '{}').build_variant_label || 'skip' }} (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Multi-Arch CI / Manifest Diff (push) Canceled after 0s
TheRock Manifest Diff Report / Generate Manifest Diff Report (push) Canceled after 0s
Multi-Arch CI / CI Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_ocl_rt images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04_rocgdb images / publish_no_rocm_image_ubuntu24_04_rocgdb (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_ocl_rt (push) Canceled after 0s
Publish TheRock Docker image / build-and-push-image (push) Canceled after 0s
Unit Tests / Unit Tests :: ubuntu-24.04 (push) Canceled after 0s
Unit Tests / Unit Tests :: windows-2022 (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_media (push) Canceled after 0s
Unit Tests / Unit Tests Summary (push) Canceled after 0s
Publish no_rocm_image_ubuntu24_04 images / publish_no_rocm_image_ubuntu24_04_openmpi (push) Canceled after 0s
106 lines
3.2 KiB
C++
106 lines
3.2 KiB
C++
//===--- CodeGenHwModes.cpp -----------------------------------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
// Classes to parse and store HW mode information for instruction selection
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "CodeGenHwModes.h"
|
|
#include "llvm/Support/Debug.h"
|
|
#include "llvm/Support/raw_ostream.h"
|
|
#include "llvm/TableGen/Error.h"
|
|
#include "llvm/TableGen/Record.h"
|
|
|
|
using namespace llvm;
|
|
|
|
StringRef CodeGenHwModes::DefaultModeName = "DefaultMode";
|
|
|
|
HwMode::HwMode(const Record *R) {
|
|
Name = R->getName();
|
|
Predicates = R->getValueAsListOfDefs("Predicates");
|
|
}
|
|
|
|
LLVM_DUMP_METHOD
|
|
void HwMode::dump() const {
|
|
dbgs() << Name << ": ";
|
|
ListSeparator LS;
|
|
for (const Record *R : Predicates)
|
|
dbgs() << LS << R->getName();
|
|
dbgs() << '\n';
|
|
}
|
|
|
|
HwModeSelect::HwModeSelect(const Record *R, CodeGenHwModes &CGH) {
|
|
std::vector<const Record *> Modes = R->getValueAsListOfDefs("Modes");
|
|
std::vector<const Record *> Objects = R->getValueAsListOfDefs("Objects");
|
|
for (auto [Mode, Object] : zip_equal(Modes, Objects)) {
|
|
unsigned ModeId = CGH.getHwModeId(Mode);
|
|
Items.emplace_back(ModeId, Object);
|
|
}
|
|
}
|
|
|
|
LLVM_DUMP_METHOD
|
|
void HwModeSelect::dump() const {
|
|
dbgs() << '{';
|
|
for (const PairType &P : Items)
|
|
dbgs() << " (" << P.first << ',' << P.second->getName() << ')';
|
|
dbgs() << " }\n";
|
|
}
|
|
|
|
CodeGenHwModes::CodeGenHwModes(const RecordKeeper &RK) : Records(RK) {
|
|
for (const Record *R : Records.getAllDerivedDefinitions("HwMode")) {
|
|
// The default mode needs a definition in the .td sources for TableGen
|
|
// to accept references to it. We need to ignore the definition here.
|
|
if (R->getName() == DefaultModeName)
|
|
continue;
|
|
Modes.emplace_back(R);
|
|
ModeIds.try_emplace(R, Modes.size());
|
|
}
|
|
|
|
assert(Modes.size() <= 32 && "number of HwModes exceeds maximum of 32");
|
|
|
|
for (const Record *R : Records.getAllDerivedDefinitions("HwModeSelect")) {
|
|
auto P = ModeSelects.emplace(R, HwModeSelect(R, *this));
|
|
assert(P.second);
|
|
(void)P;
|
|
}
|
|
}
|
|
|
|
unsigned CodeGenHwModes::getHwModeId(const Record *R) const {
|
|
if (R->getName() == DefaultModeName)
|
|
return DefaultMode;
|
|
auto F = ModeIds.find(R);
|
|
assert(F != ModeIds.end() && "Unknown mode name");
|
|
return F->second;
|
|
}
|
|
|
|
const HwModeSelect &CodeGenHwModes::getHwModeSelect(const Record *R) const {
|
|
auto F = ModeSelects.find(R);
|
|
assert(F != ModeSelects.end() && "Record is not a \"mode select\"");
|
|
return F->second;
|
|
}
|
|
|
|
LLVM_DUMP_METHOD
|
|
void CodeGenHwModes::dump() const {
|
|
dbgs() << "Modes: {\n";
|
|
for (const HwMode &M : Modes) {
|
|
dbgs() << " ";
|
|
M.dump();
|
|
}
|
|
dbgs() << "}\n";
|
|
|
|
dbgs() << "ModeIds: {\n";
|
|
for (const auto &P : ModeIds)
|
|
dbgs() << " " << P.first->getName() << " -> " << P.second << '\n';
|
|
dbgs() << "}\n";
|
|
|
|
dbgs() << "ModeSelects: {\n";
|
|
for (const auto &P : ModeSelects) {
|
|
dbgs() << " " << P.first->getName() << " -> ";
|
|
P.second.dump();
|
|
}
|
|
dbgs() << "}\n";
|
|
}
|