[InstCombine] Signed saturation tests. NFC
[llvm-complete.git] / utils / TableGen / GlobalISel / CodeExpansions.h
blobbb890ec8f57ef8b4089b200d4f88757621921f50
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_CODEEXPANSIONS_H
16 #define LLVM_UTILS_TABLEGEN_CODEEXPANSIONS_H
17 namespace llvm {
18 class CodeExpansions {
19 public:
20 using const_iterator = StringMap<std::string>::const_iterator;
22 protected:
23 StringMap<std::string> Expansions;
25 public:
26 void declare(StringRef Name, StringRef Expansion) {
27 bool Inserted = Expansions.try_emplace(Name, Expansion).second;
28 assert(Inserted && "Declared variable twice");
29 (void)Inserted;
32 std::string lookup(StringRef Variable) const {
33 return Expansions.lookup(Variable);
36 const_iterator begin() const { return Expansions.begin(); }
37 const_iterator end() const { return Expansions.end(); }
38 const_iterator find(StringRef Variable) const {
39 return Expansions.find(Variable);
42 } // end namespace llvm
43 #endif // ifndef LLVM_UTILS_TABLEGEN_CODEEXPANSIONS_H