Path: blob/main/contrib/llvm-project/llvm/utils/TableGen/Common/GlobalISel/CodeExpansions.h
35315 views
//===- CodeExpansions.h - Record expansions for CodeExpander --------------===//1//2// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.3// See https://llvm.org/LICENSE.txt for license information.4// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception5//6//===----------------------------------------------------------------------===//7//8/// \file Record the expansions to use in a CodeExpander.9//10//===----------------------------------------------------------------------===//1112#include "llvm/ADT/StringMap.h"1314#ifndef LLVM_UTILS_TABLEGEN_CODEEXPANSIONS_H15#define LLVM_UTILS_TABLEGEN_CODEEXPANSIONS_H16namespace llvm {17class CodeExpansions {18public:19using const_iterator = StringMap<std::string>::const_iterator;2021protected:22StringMap<std::string> Expansions;2324public:25void declare(StringRef Name, StringRef Expansion) {26// Duplicates are not inserted. The expansion refers to different27// MachineOperands using the same virtual register.28Expansions.try_emplace(Name, Expansion);29}3031void redeclare(StringRef Name, StringRef Expansion) {32Expansions[Name] = Expansion;33}3435std::string lookup(StringRef Variable) const {36return Expansions.lookup(Variable);37}3839const_iterator begin() const { return Expansions.begin(); }40const_iterator end() const { return Expansions.end(); }41const_iterator find(StringRef Variable) const {42return Expansions.find(Variable);43}44};45} // end namespace llvm46#endif // ifndef LLVM_UTILS_TABLEGEN_CODEEXPANSIONS_H474849