[Frontend] Remove unused includes (NFC) (#116927)
[llvm-project.git] / llvm / utils / TableGen / Common / GlobalISel / CodeExpansions.h
blob5fa8d8e6571061d538fdac0ded706be6b6671ade
1 //===- CodeExpansions.h - Record expansions for CodeExpander --------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file Record the expansions to use in a CodeExpander.
11 //===----------------------------------------------------------------------===//
13 #include "llvm/ADT/StringMap.h"
15 #ifndef LLVM_UTILS_TABLEGEN_COMMON_GLOBALISEL_CODEEXPANSIONS_H
16 #define LLVM_UTILS_TABLEGEN_COMMON_GLOBALISEL_CODEEXPANSIONS_H
18 namespace llvm {
19 class CodeExpansions {
20 public:
21 using const_iterator = StringMap<std::string>::const_iterator;
23 protected:
24 StringMap<std::string> Expansions;
26 public:
27 void declare(StringRef Name, StringRef Expansion) {
28 // Duplicates are not inserted. The expansion refers to different
29 // MachineOperands using the same virtual register.
30 Expansions.try_emplace(Name, Expansion);
33 void redeclare(StringRef Name, StringRef Expansion) {
34 Expansions[Name] = Expansion;
37 std::string lookup(StringRef Variable) const {
38 return Expansions.lookup(Variable);
41 const_iterator begin() const { return Expansions.begin(); }
42 const_iterator end() const { return Expansions.end(); }
43 const_iterator find(StringRef Variable) const {
44 return Expansions.find(Variable);
47 } // end namespace llvm
49 #endif // LLVM_UTILS_TABLEGEN_COMMON_GLOBALISEL_CODEEXPANSIONS_H