1 //===- PseudoLoweringEmitter.h - PseudoLowering Generator -------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef PSEUDOLOWERINGEMITTER_H
11 #define PSEUDOLOWERINGEMITTER_H
13 #include "CodeGenInstruction.h"
14 #include "CodeGenTarget.h"
15 #include "TableGenBackend.h"
16 #include "llvm/ADT/IndexedMap.h"
17 #include "llvm/ADT/SmallVector.h"
21 class PseudoLoweringEmitter
: public TableGenBackend
{
23 enum MapKind
{ Operand
, Imm
, Reg
};
26 unsigned Operand
; // Operand number mapped to.
27 uint64_t Imm
; // Integer immedate value.
28 Record
*Reg
; // Physical register.
31 struct PseudoExpansion
{
32 CodeGenInstruction Source
; // The source pseudo instruction definition.
33 CodeGenInstruction Dest
; // The destination instruction to lower to.
34 IndexedMap
<OpData
> OperandMap
;
36 PseudoExpansion(CodeGenInstruction
&s
, CodeGenInstruction
&d
,
37 IndexedMap
<OpData
> &m
) :
38 Source(s
), Dest(d
), OperandMap(m
) {}
41 RecordKeeper
&Records
;
43 // It's overkill to have an instance of the full CodeGenTarget object,
44 // but it loads everything on demand, not in the constructor, so it's
45 // lightweight in performance, so it works out OK.
48 SmallVector
<PseudoExpansion
, 64> Expansions
;
50 unsigned addDagOperandMapping(Record
*Rec
, DagInit
*Dag
,
51 CodeGenInstruction
&Insn
,
52 IndexedMap
<OpData
> &OperandMap
,
54 void evaluateExpansion(Record
*Pseudo
);
55 void emitLoweringEmitter(raw_ostream
&o
);
57 PseudoLoweringEmitter(RecordKeeper
&R
) : Records(R
), Target(R
) {}
59 /// run - Output the pseudo-lowerings.
60 void run(raw_ostream
&o
);
63 } // end llvm namespace