1 //===--- CodeGenHwModes.h ---------------------------------------*- C++ -*-===//
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
7 //===----------------------------------------------------------------------===//
8 // Classes to parse and store HW mode information for instruction selection.
9 //===----------------------------------------------------------------------===//
11 #ifndef LLVM_UTILS_TABLEGEN_CODEGENHWMODES_H
12 #define LLVM_UTILS_TABLEGEN_CODEGENHWMODES_H
14 #include "llvm/ADT/DenseMap.h"
15 #include "llvm/ADT/StringRef.h"
22 // HwModeId -> list of predicates (definition)
28 struct CodeGenHwModes
;
34 std::string Predicates
;
39 HwModeSelect(Record
*R
, CodeGenHwModes
&CGH
);
40 typedef std::pair
<unsigned, Record
*> PairType
;
41 std::vector
<PairType
> Items
;
45 struct CodeGenHwModes
{
46 enum : unsigned { DefaultMode
= 0 };
47 static StringRef DefaultModeName
;
49 CodeGenHwModes(RecordKeeper
&R
);
50 unsigned getHwModeId(Record
*R
) const;
51 const HwMode
&getMode(unsigned Id
) const {
52 assert(Id
!= 0 && "Mode id of 0 is reserved for the default mode");
55 const HwModeSelect
&getHwModeSelect(Record
*R
) const;
56 unsigned getNumModeIds() const { return Modes
.size()+1; }
60 RecordKeeper
&Records
;
61 DenseMap
<Record
*, unsigned> ModeIds
; // HwMode Record -> HwModeId
62 std::vector
<HwMode
> Modes
;
63 std::map
<Record
*,HwModeSelect
> ModeSelects
;
67 #endif // LLVM_UTILS_TABLEGEN_CODEGENHWMODES_H